Skip to content

Instantly share code, notes, and snippets.

@thephysicsvirtuosi
Created March 14, 2012 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thephysicsvirtuosi/2033970 to your computer and use it in GitHub Desktop.
Save thephysicsvirtuosi/2033970 to your computer and use it in GitHub Desktop.
Primes in Pi
#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