login
A343422
Number of digits of earliest prime encountered at each digit n of the decimal expansion of Pi.
0
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,2
COMMENTS
The underlying approach is an alternate way to spawn primes from Pi (and other irrational values) compared to A005042. Generally speaking, there should be a prime for every known digit (sequence is likely infinite, use -1 for any term without solution). By its construction, every prime will not be encountered, and primes will be repeated, especially 2,3,5 and 7. Large primes will be seen within the prime sequence. Note that concatenations with leading 0 will duplicate that of the subsequent concatenation having nonzero leading digit.
The corresponding primes are: 3, 14159, 41, 1592653, 5, 9265358979323, 2, 653, 5, 3, 5, 89, 97, 7, 9323, 3, 2, 3, ....
FORMULA
a(A153031(n)) = 1. - Michel Marcus, Aug 22 2021
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Bill McEachen, Aug 21 2021
STATUS
approved