Last active
August 29, 2015 14:24
-
-
Save cswiercz/16db3d47098c7910422b to your computer and use it in GitHub Desktop.
Computing "Small" Gaussian Primes
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
from sympy import isprime | |
from itertools import ifilter, count | |
def find_b(a): | |
"""Returns smallest b such that a^2 + b^2 is prime.""" | |
f = lambda b: isprime(a**2 + b**2) | |
g = ifilter(f, count()) | |
b = g.next() | |
return b | |
# for each a = 1,...,N compute the smallest b | |
# such that a+bi is a Gaussian prime | |
N = 10000 | |
a = range(1, N) | |
b = map(find_b, a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment