login
Out of all the n-digit primes, which one takes the longest time to appear in the digits of Pi (ignoring the initial 3)? The answer is a(n), and it appears at position A076130(n).
3

%I #18 Jul 08 2021 10:40:37

%S 7,73,373,9337,35569,805289,9271903

%N Out of all the n-digit primes, which one takes the longest time to appear in the digits of Pi (ignoring the initial 3)? The answer is a(n), and it appears at position A076130(n).

%C a(8) requires > 1 billion digits of Pi. - _Michael S. Branicky_, Jul 08 2021

%H Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_040.htm">Puzzle 40. The Pi Prime Search Puzzle (by Patrick De Geest)</a>, The Prime Puzzles and Problems Connection.

%e Of all the 2-digit primes, 11 to 97, the last one to appear in Pi is 73, at position 299 (see A076130). - _N. J. A. Sloane_, Nov 28 2019

%o (Python)

%o # download https://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt, then

%o with open('pi-billion.txt', 'r') as f: digits_of_pi = f.readline()[2:]

%o # from sympy import S

%o # digits_of_pi = str(S.Pi.n(72*10**4))[2:] # alternate to loading data

%o from sympy import primerange

%o def A076106_A076130(n):

%o global digits_of_pi

%o bigp, bigloc = None, -1

%o for p in primerange(10**(n-1), 10**n):

%o loc = digits_of_pi.find(str(p))

%o if loc == -1: print("not enough digits", n, p)

%o if loc > bigloc:

%o bigloc = loc

%o bigp = p

%o return (bigp, bigloc+1)

%o print([A076106_A076130(n)[0] for n in range(1, 6)]) # _Michael S. Branicky_, Jul 08 2021

%Y Cf. A000796, A047658, A076094, A076129, A076130.

%K hard,more,nonn,base

%O 1,1

%A Jean-Christophe Colin (jc-colin(AT)wanadoo.fr), Oct 31 2002

%E Definition clarified by _N. J. A. Sloane_, Nov 28 2019

%E a(7) from _Michael S. Branicky_, Jul 08 2021