A198344 Position of the first n-digit prime occurring in the decimal expansion of Pi, A000796.
1, 1, 8, 3, 2, 1, 4, 34, 30, 5, 15, 2, 6, 17, 36, 82, 12, 87, 26, 12, 25, 215, 35, 18, 17, 3, 41, 17, 234, 17, 167, 92, 251, 15, 9, 12, 31, 1, 57, 290, 4, 99, 218, 502, 48, 164, 198, 201, 128, 7, 363, 143, 11, 138, 487, 32, 230, 82, 355, 515, 334, 186, 176, 223
Offset: 1
Examples
a(1)=1 because the initial digit "3" of Pi is prime. a(2)=a(6)=a(38)=1 because the first 2, 6, and 38 digits of Pi (including the initial 3) also form the primes 31, 314159 and 31415926535897932384626433832795028841, cf. A005042 and A060421.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1000 (terms 1..162 from M. F. Hasler)
Programs
-
Mathematica
With[{pd=RealDigits[Pi,10,1000][[1]]},Table[Position[Partition[pd,n,1],?(PrimeQ[FromDigits[#]]&&#[[1]]!=0&),{1},1,Heads->False],{n,60}]]// Flatten (* _Harvey P. Dale, Apr 25 2016 *)
-
PARI
A198344(n)=for(c=0,9e9,ispseudoprime(Pi\.1^(n+c-1)%10^n)&Pi\.1^c%10&return(c+1)) /* Replace upper limit 9e9 by "default(realprecision)-n" to avoid an error message and return 0 in case no n-digit prime is found */
-
Python
# uses code in A104841 print([A104841_A198344(n)[1] for n in range(1, 65)]) # Michael S. Branicky, Dec 28 2022
Comments