login
A114017
a(n) = smallest n-digit prime which differs from the previous n-digit prime at every corresponding digit (or 0 if no such prime exists).
1
3, 23, 211, 2003, 20011, 200003, 3000017, 20000003, 200000033, 2000000011, 20000000089, 300000000077, 2000000000003, 20000000000021, 400000000000063, 2000000000000021, 50000000000000051, 200000000000000003
OFFSET
1,1
COMMENTS
For n > 1, a(n), if it exists, is of the form nextprime(t*10^(n-1)) for some t, 2 <= t <= 9. [Max Alekseyev, Apr 23 2010]
EXAMPLE
2003 is a term as the previous prime 1999 differs at every corresponding position (1,2), (9,0), (9,0), (9,3).
MATHEMATICA
Table[SelectFirst[Partition[Prime@ Range[PrimePi@ NextPrime[10^n], PrimePi[10^(n + 1) - 1]], 2, 1], AllTrue[Transpose@ {IntegerDigits[#1], IntegerDigits[#2]}, UnsameQ @@ # &] & @@ # &], {n, 0, 7}] [[All, -1]] (* Michael De Vlieger, Aug 14 2017 *)
PROG
(PARI) { a(n) = local(L, U, aa, bb); if(n==1, return(3)); for(t=2, 9, L=precprime(t*10^(n-1)); U=nextprime(t*10^(n-1)); aa=Vec(Str(L)); bb=Vec(Str(U)); if(sum(i=1, #aa, aa[i]!=bb[i])==#aa, return(U)); ); 0 } \\ Max Alekseyev, Apr 23 2010
CROSSREFS
Cf. A114016.
Sequence in context: A235131 A235360 A135423 * A316085 A068691 A093135
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Nov 12 2005
EXTENSIONS
2 more terms from R. J. Mathar, Aug 31 2007
More terms from Max Alekseyev, Apr 23 2010
STATUS
approved