A104842 Position of the first sequence of n subsequent digits of Pi which form a prime.
1, 1, 8, 3, 2, 1, 4, 34, 30, 5, 15, 2, 6, 17, 36, 82, 12, 87, 26, 12, 25, 133, 35, 18, 17, 3, 41, 17, 234, 17, 167, 92, 251, 15, 9, 12, 31, 1, 57, 290, 4, 99, 98, 502, 48, 164, 198, 201, 128, 7, 363, 143, 11, 138, 196, 32, 230, 82, 292, 515, 334, 186, 176, 223, 57, 135, 35
Offset: 1
Examples
a(1)=1 since the first single-digit prime found, 3, is at first place, hence a(1)=1, a(2)=1 since the first two-digit prime found, 31, is at first place, hence a(2)=1, a(3)=8 since the first three-digit prime found, 653, is at 8th place, hence a(3)=8, ...
Programs
-
Mathematica
pi = RealDigits[Pi, 10, 100][[1]]; f[n_] := Block[{k = 1}, While[ !PrimeQ[ FromDigits[ Take[pi, {k, k + n - 1}]]], k++ ]; k]; Table[ f[n], {n, 67}] (* Robert G. Wilson v, Mar 29 2005 *)
-
PARI
a(n)={for(c=-1,default(realprecision)-n-2,ispseudoprime(Pi\.1^(n+c)%10^n)&return(c+2));error("Insufficient realprecision, please increase.")} \\ M. F. Hasler, Oct 23 2011
Extensions
More terms from a(33) onward from Robert G. Wilson v, Mar 29 2005
Comments