Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #102 Sep 21 2021 07:10:01
%S 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,
%T 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,
%U 45,35,1,30,1,1,1,1,4834,24,341,86,127,127,1,143
%N Number of digits of earliest prime encountered at each digit n of the decimal expansion of Pi.
%C 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.
%C The corresponding primes are: 3, 14159, 41, 1592653, 5, 9265358979323, 2, 653, 5, 3, 5, 89, 97, 7, 9323, 3, 2, 3, ....
%H RosettaCode, <a href="https://rosettacode.org/wiki/Pi#PARI.2FGP">Digits of Pi</a>
%F a(A153031(n)) = 1. - _Michel Marcus_, Aug 22 2021
%e The first term is the trivial prime 3, having length=1 digit, so a(1)=1.
%e 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.
%e The next evaluation starts at digit 4: 4 is composite, 41 is prime, so a(3)=2.
%e The 33rd and 34th digits of Pi are 0 and 2, and "02" converts to 2, a 1-digit prime. Thus, a(33) = 1.
%o (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
%o (Python)
%o from sympy import S, isprime
%o pi_digits = str(S.Pi.n(10**5+1)).replace(".", "")[:-1]
%o def a(n):
%o s, k = pi_digits[n-1], 1
%o while not isprime(int(s)):
%o s, k = s + pi_digits[n-1+k], k + 1
%o return len(str(int(s)))
%o print([a(n) for n in range(1, 19)]) # _Michael S. Branicky_, Aug 21 2021
%Y Cf. A005042, A073264, A153031.
%K nonn,base,easy
%O 1,2
%A _Bill McEachen_, Aug 21 2021