%I #56 Feb 28 2018 22:33:01
%S 3,31,13147,73141,314159,314159,131415923,1314159269,23141592653,
%T 23141592653,314159265359,3141592653581,213141592653589,
%U 1131415926535897,9314159265358979,173141592653589793,3141592653589793239,3141592653589793239,314159265358979323861
%N a(n) is the smallest prime number whose representation contains as a substring the first n digits of Pi in base 10.
%C Pi progresses as 3, 31, 314, 3141, hence minimal prime numbers that do this are 3, 31, 13147, 73141. While there are other primes that contain, say, 314, the prime number, 13147 is the first prime to do so.
%C It is probably provable that this is an infinite sequence. Notice that 314159 appears twice in the sequence since 314159 is the smallest prime that contains 31415 as well as 314159.
%C a(n) exists for all n since for sufficiently large k, the k-th prime gap < prime(k)^d for some d < 1, so for a fixed number a, the next prime after a*10^m will be less than (a+1)*10^m for sufficiently large m and thus contain a as a substring. - _Chai Wah Wu_, Feb 22 2018
%H Chai Wah Wu, <a href="/A283247/b283247.txt">Table of n, a(n) for n = 1..997</a>
%H Manan Shah, <a href="http://mathmisery.com/wp/2017/07/19/summer-excursion-3-a-pi-containing-prime-number-sequence-challenge/">A Pi Containing Prime Number Sequence</a>
%e a(4) = 73141 since 73141 is the smallest prime number that contains 3141 (the first 4 digits of Pi).
%e a(5) = 314159 since 314159 is the smallest prime number that contains 31415.
%e a(6) = 314159 since 314159 is the smallest prime number that contains 314159.
%t pp[n_] := If[PrimeQ@n, n, Block[{d = IntegerDigits@n, p, s, t}, p = 10^Length[d]; s = Select[Join[Range[9] p + n, {1,3,7,9} + 10 n], PrimeQ]; If[s != {}, Min@s, s = NextPrime[100 n]; t = Join[If[Floor[s/100] == n, {s}, {}], Range[10, 99] p + n, FromDigits /@ Flatten /@ Tuples[{Range@9, {d}, {1, 3, 7, 9}}]]; s = Select[t, PrimeQ]; If[s == {}, 0, Min@s]]]]; Table[pp[Floor[10^e Pi]], {e, 0, 18}] (* _Giovanni Resta_, Jul 21 2017 *)
%o (Python 3.6.x)
%o pi_digits = pi_digit_generator #user-defined generator for producing next digit of Pi
%o next_digit = pi_digits.next() #first call, so next_digit = 3
%o primes = prime_generator #user-defined generator for producing next prime
%o current_prime = primes.next() #first call, so current_prime = 2
%o pi_progress = 0
%o while True:
%o pi_progress = pi_progress*10 + next_digit
%o while str(pi_progress) not in str(current_prime):
%o current_prime = primes.next()
%o print(pi_progress,current_prime)
%Y Cf. A005042, A282973.
%K nonn,base
%O 1,1
%A _Manan Shah_, Jul 20 2017
%E a(7)-a(19) from _Giovanni Resta_, Jul 21 2017
|