Skip to content

Instantly share code, notes, and snippets.

@zhangys-lucky
Created August 19, 2015 00:44
Show Gist options
  • Save zhangys-lucky/dda78b5fa2eb44253af9 to your computer and use it in GitHub Desktop.
Save zhangys-lucky/dda78b5fa2eb44253af9 to your computer and use it in GitHub Desktop.
generate prime table with some tricks
#! /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