login
A377370
Smallest prime ending in n alternating decimal digits 0 and 1.
1
11, 101, 101, 20101, 210101, 4010101, 61010101, 1601010101, 8101010101, 260101010101, 3110101010101, 11010101010101, 11010101010101, 1201010101010101, 6101010101010101, 180101010101010101, 1710101010101010101, 5010101010101010101, 41010101010101010101
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
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
Sequence in context: A318647 A185121 A391444 * A133835 A326108 A292451
KEYWORD
nonn,base
AUTHOR
James S. DeArmon, Dec 27 2024
STATUS
approved