login
Number of ways a digit can be appended or prepended to n and form a prime.
2

%I #43 May 24 2024 01:32:19

%S 4,9,3,9,3,3,2,9,2,6,4,6,1,7,1,2,2,5,1,9,0,4,3,6,1,2,2,6,2,5,1,8,0,5,

%T 2,2,1,6,2,6,2,6,1,7,2,1,3,6,1,5,2,3,2,5,2,1,2,8,1,6,2,7,0,6,3,2,1,7,

%U 1,4,2,5,1,7,1,2,2,6,1,5,1,4,4,7,0,3,1

%N Number of ways a digit can be appended or prepended to n and form a prime.

%C The prime number may be formed by adding a digit either before or after n, though only odd numbers can become prime by having digits added before n.

%C Appending a zero before n produces a prime if and only if n is prime. Conversely, for all prime numbers p, a(p) > 0.

%C In theory, a maximum of 7 digits could be added before any n, and 3 of the odd digits after n in cases where [10*n, 10*n+9] contains a number that is a factor of 3, 5 and 7 (the three single-digit odd primes). In practice, it appears that all 10 possibilities are never realized. There are 9 possibilities for n = {1, 3, 7, 19}.

%C The only example of a prime being formed two different ways is for n = 1, which can become 11 if a 1 is appended to either the front or the back. These are naively counted as two distinct alternatives. [This would also be true for n = A002275(A004023(k) - 1) for k > 1 as appending a 1 to either the front or the back forms the k-th repunit prime. - _Michael S. Branicky_, May 22 2024]

%C The term a(29587) is the first occurrence of 10. The primes are 29587, 129587, 329587, 429587, 729587, 929587, 295871, 295873, 295877, and 295879. This is the only occurrence of 10 for n < 10^8. - _T. D. Noe_, Apr 21 2013

%H Christian N. K. Anderson, <a href="/A224953/b224953.txt">Table of n, a(n) for n = 0..9999</a>

%H Christian N. K. Anderson, <a href="/A224953/a224953.txt">Primes formed by appending digits to n for n = 0..9999</a>

%e a(0) = 4 because there are 4 ways to concatenate a digit to 0 to produce a prime number: 02, 03, 05, and 07.

%e a(3) = 9 because a digit can be concatenated to 3 in 9 ways to produce a prime number: 03, 13, 23, 43, 53, 73, 83, 31, and 37.

%t Table[num = IntegerDigits[n]; cnt = 0; Do[If[PrimeQ[FromDigits[Prepend[num, k]]], cnt++], {k, 0, 9}]; Do[If[PrimeQ[FromDigits[Append[num, k]]], cnt++], {k, 0, 9}]; cnt, {n, 0, 86}] (* _T. D. Noe_, Apr 20 2013 *)

%o (R) sapply(1:100, function(x) sum(sapply(as.numeric(c(paste0(0:9,x), paste0(x,c(1,3,7,9)))), is_prime ))) # _Christian N. K. Anderson_, Apr 30 2024

%Y Cf. A087388, A087389, A087390.

%Y Cf. A069686.

%Y Cf. A075595.

%Y Cr. A002275, A004023.

%Y Index of zeros in this sequence: A124665.

%K nonn,base

%O 0,1

%A _Christian N. K. Anderson_ and _Kevin L. Schwartz_, Apr 20 2013