Created
July 6, 2017 12:06
-
-
Save akiross/3dbab3d77853e77edb1f2e1fccbd1497 to your computer and use it in GitHub Desktop.
Generating prime numbers in chunks
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
def extend(old, new): | |
for p in old: | |
cand = [] | |
for n in new: | |
if n % p != 0: | |
cand.append(n) | |
if not cand: | |
return old | |
old.append(cand[0]) | |
new = cand[1:] | |
extend([2], range(3, 10)) # [2, 3, 5, 7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment