Created
December 16, 2017 03:09
-
-
Save ssanin82/ee78bef0dc2f649ab40360e562a26d19 to your computer and use it in GitHub Desktop.
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 get_primes_to(n): | |
D, q = {}, 2 | |
while q <= n: | |
if q not in D: | |
yield q | |
D[q * q] = [q] | |
else: | |
for p in D[q]: | |
D.setdefault(p + q, []).append(p) | |
del D[q] | |
q += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment