cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A343422 Number of digits of earliest prime encountered at each digit n of the decimal expansion of Pi.

This page as a plain text file.
%I A343422 #102 Sep 21 2021 07:10:01
%S A343422 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 A343422 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 A343422 45,35,1,30,1,1,1,1,4834,24,341,86,127,127,1,143
%N A343422 Number of digits of earliest prime encountered at each digit n of the decimal expansion of Pi.
%C A343422 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 A343422 The corresponding primes are: 3, 14159, 41, 1592653, 5, 9265358979323, 2, 653, 5, 3, 5, 89, 97, 7, 9323, 3, 2, 3, ....
%H A343422 RosettaCode, <a href="https://rosettacode.org/wiki/Pi#PARI.2FGP">Digits of Pi</a>
%F A343422 a(A153031(n)) = 1. - _Michel Marcus_, Aug 22 2021
%e A343422 The first term is the trivial prime 3, having length=1 digit, so a(1)=1.
%e A343422 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 A343422 The next evaluation starts at digit 4:  4 is composite, 41 is prime, so a(3)=2.
%e A343422 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 A343422 (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 A343422 (Python)
%o A343422 from sympy import S, isprime
%o A343422 pi_digits = str(S.Pi.n(10**5+1)).replace(".", "")[:-1]
%o A343422 def a(n):
%o A343422     s, k = pi_digits[n-1], 1
%o A343422     while not isprime(int(s)):
%o A343422         s, k = s + pi_digits[n-1+k], k + 1
%o A343422     return len(str(int(s)))
%o A343422 print([a(n) for n in range(1, 19)]) # _Michael S. Branicky_, Aug 21 2021
%Y A343422 Cf. A005042, A073264, A153031.
%K A343422 nonn,base,easy
%O A343422 1,2
%A A343422 _Bill McEachen_, Aug 21 2021