Created
February 12, 2012 00:13
-
-
Save RSully/1805262 to your computer and use it in GitHub Desktop.
Prime generator - draft concept of 6n±1
This file contains hidden or 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
prev = [] | |
start = 5 | |
num = start | |
lastPrime = (0,0) | |
ctr = 2 # 5 is the 3rd prime | |
while ctr < 50000: | |
isPrime = not any(num % n == 0 for n in prev) | |
if isPrime: | |
ctr += 1 | |
lastPrime = (ctr, num) | |
prev.append(num) | |
if (num+1) % 6 == 0: | |
num += 2 | |
else: | |
num += 4 | |
print "%d\t%d" % lastPrime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment