Skip to main content
I put the wrong number of bytes. Fixed.
Source Link
0WJYxW9FMN
  • 2.8k
  • 13
  • 34

Python 3, 107117 106 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in[2]+[i*(not 0 in[i%j for j in r(3,int(i**0.5)+1,2)])for i in r(3,int(input()),2)]:print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Python 3, 107 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in[2]+[i*(not 0 in[i%j for j in r(3,int(i**0.5)+1,2)])for i in r(3,int(input()),2)]:print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Python 3, 117 106 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in[2]+[i*(not 0 in[i%j for j in r(3,int(i**0.5)+1,2)])for i in r(3,int(input()),2)]:print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Shortened the code.
Source Link
0WJYxW9FMN
  • 2.8k
  • 13
  • 34

Python 3, 117107 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in [2]+[0 ifin[2]+[i*(not 0 in [i%jin[i%j for j in r(3,int(i**0.5)+1,2)] else i )for i in r(3,int(input()),2)]:
    print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Python 3, 117 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in [2]+[0 if 0 in [i%j for j in r(3,int(i**0.5)+1,2)] else i for i in r(3,int(input()),2)]:
    print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Python 3, 107 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in[2]+[i*(not 0 in[i%j for j in r(3,int(i**0.5)+1,2)])for i in r(3,int(input()),2)]:print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.

Source Link
0WJYxW9FMN
  • 2.8k
  • 13
  • 34

Python 3, 117 bytes

This solution is slightly trivial, as it outputs 0 where a number is not prime, but I'll post it anyway:

r=range
for i in [2]+[0 if 0 in [i%j for j in r(3,int(i**0.5)+1,2)] else i for i in r(3,int(input()),2)]:
    print(i)

Also, I'm not sure how to work out the complexity of an algorithm. Please don't downvote because of this. Instead, be nice and comment how I could work it out. Also, tell me how I could shorten this.