OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Dave Andersen, The Pi-Search Page
EXAMPLE
Pi = 3.14159265358979323846264338327950288... (see A000796).
First occurrence of prime(23) = 83 starts at the 26th digit after the decimal point, hence a(23) = 26.
MATHEMATICA
Module[{p = Rest[First[RealDigits[Pi, 10, 10^4]]], n = 0, a}, Reap[While[(a = SequencePosition[p, IntegerDigits[Prime[++n]], 1]) != {}, Sow[a[[1, 1]]]]][[2, 1]]] (* Paolo Xausa, Aug 01 2024 *)
PROG
(Magma) k:=3500; R := RealField(k); [ Position(IntegerToString(Round(10^k*(-3 + Pi(R)))), IntegerToString(NthPrime(n))) : n in [1..55] ]; /* Klaus Brockhaus, Feb 15 2007 */
(Python)
from itertools import takewhile
from sympy import S, prime, primerange
# download https://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt, then
# with open('pi-billion.txt', 'r') as f: pi_digits = f.readline()[1:]
pi_digits = str(S.Pi.n(10**4))[1:] # alternative to above
def aupton(nn):
plocs = (pi_digits.find(str(p)) for p in primerange(2, prime(nn)+1))
return list(takewhile(lambda x: x>=0, plocs)) # until p not found
print(aupton(55)) # Michael S. Branicky, Jun 12 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Patrick De Geest, Jan 04 1999
EXTENSIONS
Edited by Klaus Brockhaus, Feb 15 2007
STATUS
approved