Created
March 14, 2012 04:02
-
-
Save thephysicsvirtuosi/2033970 to your computer and use it in GitHub Desktop.
Primes in Pi
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
#Figure out some primes in consecutive digits of pi | |
from sympy import * | |
N = 1000 | |
pidigits = ["3"] + list(str(pi.evalf(N)))[2:] | |
for end in xrange(1,N-1): | |
candidate = int("".join(pidigits[:end])) | |
if int(pidigits[end]) >= 5: | |
rounded = candidate + 1 | |
if isprime(rounded): | |
print "Found a rounded one with {} digits, is: {}".format(end,rounded) | |
if isprime(candidate): | |
print "Found one, with {} digits, is: {}".format(end,candidate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment