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.

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

Original entry on oeis.org

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, 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, 1, 4, 2, 5, 1, 7, 1, 2, 2, 6, 1, 5, 1, 4, 4, 7, 0, 3, 1
Offset: 0

Views

Author

Keywords

Comments

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.
Appending a zero before n produces a prime if and only if n is prime. Conversely, for all prime numbers p, a(p) > 0.
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}.
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]
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

Examples

			a(0) = 4 because there are 4 ways to concatenate a digit to 0 to produce a prime number: 02, 03, 05, and 07.
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.
		

Crossrefs

Cf. A069686.
Cf. A075595.
Index of zeros in this sequence: A124665.

Programs

  • Mathematica
    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 *)
  • 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