Skip to content

Instantly share code, notes, and snippets.

@zigzackey
Created March 29, 2016 04:34
Show Gist options
  • Save zigzackey/524a501c102de3132aa8 to your computer and use it in GitHub Desktop.
Save zigzackey/524a501c102de3132aa8 to your computer and use it in GitHub Desktop.
import math
def sieve(x):
prime = [True for i in range(x)]
for i in range(2, int(math.sqrt(x))):
if prime[i] == True:
j = 0
while i * (j + 2) < x:
prime[i * (j + 2)] = False
j = j + 1
for i in range(2, x):
if prime[i] == True:
print(i)
if __name__ == '__main__':
N = int(input())
sieve(N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment