A383743 a(n) is the smallest prime not yet in the sequence that satisfies the following: for some pair of different digits i and j in a(n-1), i preceding j (from left to right), j precedes i in a(n). Leading 0s are not allowed; a(1)=13. See Comments for details.
13, 31, 103, 101, 107, 71, 17, 271, 127, 211, 1021, 109, 191, 19, 491, 139, 131, 113, 311, 137, 73, 37, 173, 307, 373, 317, 163, 61, 167, 461, 149, 41, 1049, 241, 421, 1123, 251, 151, 157, 521, 257, 523, 353, 53, 359, 193, 239, 293, 349, 43, 347, 431
Offset: 1
Examples
In a(2)=31 3 precedes 1, hence a(3)=103 since it is the smallest prime not yet in the sequence in which the digit 1 precedes 3. In a(3)=103 1 precedes 0, hence a(4)=101 since it is the smallest prime not yet in the sequence in which the digit 0 precedes 1 (last two digits). In a(10)=211 2 precedes 1, hence a(11)=1021 since it is the smallest prime not yet in the sequence in which the digit 1 precedes 2 (first and third digits). In a(11)=1021 0 precedes 1 (second and fourth digits), hence a(12)=109 since it is the smallest prime not yet in the sequence in which the digit 1 precedes 0 (first and second digits).
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
- Sean A. Irvine, Java program (github)
Programs
-
Maple
P:= select(isprime,[seq(i,i=13 .. 1000,2)]): g:= proc(n) local L, R,i,j; L:= convert(n,base,10); R:= select(t -> t[2] <> t[1], {seq(seq([L[i],L[j]],j=1..i-1),i=1..nops(L))}); end proc: R:= 13: r:= 13: Cands:= subsop(1=NULL,P): do qr:= map(t -> [t[2],t[1]],g(r)): found:= false; for i from 1 to nops(Cands) do if g(Cands[i]) intersect qr <> {} then r:= Cands[i]; R:= R,r; Cands:= subsop(i=NULL,Cands); found:= true; break fi od; until not found: R; # Robert Israel, Jun 09 2025
Comments