OFFSET
1,1
COMMENTS
Leading zeros are not allowed, so that prime p = 101 does not end 0101 and is not a candidate for a(4).
For n>=5, the ending is not itself prime, so that the prefix must be a positive integer.
Some terms are repeated, e.g., 11010101010101 ends with "010101010101" and also ends with the next element in alternating series "1010101010101".
LINKS
Robert Israel, Table of n, a(n) for n = 1..992
EXAMPLE
For n=4, the required ending is the 4 digits 0101, and the smallest prime ending that way is a(4) = 20101.
MAPLE
f:= proc(n) local t0, t, k;
t0:= add(10^k, k=0..n-1, 2);
if n::even then t0:=t0 + 10^n fi;
for t from t0 by 10^n do if isprime(t) then return t fi od
end proc:
map(f, [$1..20]); # Robert Israel, Feb 26 2025
MATHEMATICA
s={}; d={}; Do[If[OddQ[n], PrependTo[d, 1], PrependTo[d, 0]]; If[PrimeQ[FromDigits[d]&&OddQ[n]], p=FromDigits[d], i=0; p=FromDigits[Prepend[d, i]]; Until[PrimeQ[p], i++; p=FromDigits[Prepend[d, i]]]]; AppendTo[s, p], {n, 19}]; s (* James C. McMahon, Feb 08 2025 *)
PROG
(Python)
from sympy import isprime
from itertools import count
def a(n):
ending = int(("01"*n)[-n:])
if n&1 and isprime(ending): return ending
return next(i for i in count(10**n+ending, 10**n) if isprime(i))
print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Jan 26 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
James S. DeArmon, Dec 27 2024
STATUS
approved
