A343422 Number of digits of earliest prime encountered at each digit n of the decimal expansion of Pi.
1, 5, 2, 7, 1, 13, 1, 3, 1, 1, 1, 2, 2, 1, 4, 1, 1, 1, 3057, 6, 3490, 1, 3, 2, 1, 1, 2, 1, 1, 1, 20, 1, 1, 1, 9, 4, 2, 2, 2, 1, 4, 7, 6329, 1, 53, 3, 1, 1, 1, 19128, 1, 1, 4, 1, 2, 2, 1, 12, 39, 45, 35, 1, 30, 1, 1, 1, 1, 4834, 24, 341, 86, 127, 127, 1, 143
Offset: 1
Examples
The first term is the trivial prime 3, having length=1 digit, so a(1)=1. The next evaluation starts at digit 1: 1 is not prime, 14 is composite, 141 is composite, 1415 is composite, but 14159 is prime, so a(2)=5. The next evaluation starts at digit 4: 4 is composite, 41 is prime, so a(3)=2. The 33rd and 34th digits of Pi are 0 and 2, and "02" converts to 2, a 1-digit prime. Thus, a(33) = 1.
Links
- RosettaCode, Digits of Pi
Programs
-
PARI
lista(p) = {default(realprecision, p); my(x=Pi, nb=#Str(x), d=digits(floor(x*10^(nb-1)))); for (i=1, #d, my(k=i, j=d[i]); while (! ispseudoprime(j), k++; if (k>#d, j=0; break, j = 10*j+d[k])); if (j==0, break, print1(#Str(j), ", ")););} \\ Michel Marcus, Sep 15 2021
-
Python
from sympy import S, isprime pi_digits = str(S.Pi.n(10**5+1)).replace(".", "")[:-1] def a(n): s, k = pi_digits[n-1], 1 while not isprime(int(s)): s, k = s + pi_digits[n-1+k], k + 1 return len(str(int(s))) print([a(n) for n in range(1, 19)]) # Michael S. Branicky, Aug 21 2021
Formula
a(A153031(n)) = 1. - Michel Marcus, Aug 22 2021
Comments