Skip to content

Instantly share code, notes, and snippets.


tylerkerr/ Secret

Last active Jun 18, 2017
What would you like to do?
#!/usr/bin/env python3
import sys
def main():
start, end = 0, int(sys.argv[1])
primelist = [True] * (end+1) # populate array with Trues from 0
primelist[0], primelist[1] = False, False # 0 and 1 are not primes
for i in range(2, int(end ** 0.5)+1): # the sieve
if primelist[i]:
j = i ** 2
while j < end+1:
primelist[j] = False
j += i
count = 0
for (n, prime) in enumerate(primelist): # print any numbers marked as True
if prime:
count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.