A377370 Smallest prime ending in n alternating decimal digits 0 and 1.
11, 101, 101, 20101, 210101, 4010101, 61010101, 1601010101, 8101010101, 260101010101, 3110101010101, 11010101010101, 11010101010101, 1201010101010101, 6101010101010101, 180101010101010101, 1710101010101010101, 5010101010101010101, 41010101010101010101
Offset: 1
Examples
For n=4, the required ending is the 4 digits 0101, and the smallest prime ending that way is a(4) = 20101.
Links
- Robert Israel, Table of n, a(n) for n = 1..992
Programs
-
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 *)
-
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
Comments