Created
August 19, 2015 00:44
-
-
Save zhangys-lucky/dda78b5fa2eb44253af9 to your computer and use it in GitHub Desktop.
generate prime table with some tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
from is_prime import is_prime | |
prime = [i * 0 for i in range(1000)] | |
prime[0] = 1 | |
prime[1] = 2 | |
prime[2] = 3 | |
i = 5 | |
step = 4 | |
prime_size = 3 | |
while i <= 1000: | |
if is_prime(i) == True: | |
prime[prime_size] = i | |
prime_size += 1 | |
step ^= 6 | |
i += step | |
print(prime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment