A382899 The smallest n-digit prime that turns composite at each step as its digits are successively appended, starting from the first.
2, 11, 101, 1013, 10007, 100003, 1000003, 10000019, 100000007, 1000000007, 10000000019, 100000000003, 1000000000061, 10000000000037, 100000000000031, 1000000000000037, 10000000000000061, 100000000000000013, 1000000000000000003, 10000000000000000051
Offset: 1
Examples
a(1) = 2, because 2 is prime, 22 = 2*11 is composite, while no smaller one-digit prime exhibits this property. a(2) = 11, because 11 is prime, 111 = 3*37 and 1111 = 11*101 are composite, while no smaller two-digit prime exhibits this property. a(4) = 1013, because 1013 is prime, 10131 = 3 * 11 * 30, 101310 = 2 * 3 * 5 * 11 * 307, 1013101 = 227 * 4463 and 10131013 = 73 * 137 * 1013 are composite, while no smaller 4-digit prime exhibits this property.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1000
Programs
-
PARI
isok(p, n) = my(d=digits(p)); for (i=1, #d, p = 10*p+d[i]; if (isprime(p), return(0));); return(1); a(n) = my(p=nextprime(10^(n-1))); while (!isok(p, n), p = nextprime(p+1)); p; \\ Michel Marcus, Apr 09 2025
-
Python
from sympy import isprime, nextprime def c(s): # check if prime p's string of digits meets the concatenation condition return not any(isprime(int(s:=s+c)) for c in s) def a(n): p = nextprime(10**(n-1)) while not c(str(p)): p = nextprime(p) return p print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Apr 09 2025