This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A383743 #21 Jun 15 2025 22:53:54 %S A383743 13,31,103,101,107,71,17,271,127,211,1021,109,191,19,491,139,131,113, %T A383743 311,137,73,37,173,307,373,317,163,61,167,461,149,41,1049,241,421, %U A383743 1123,251,151,157,521,257,523,353,53,359,193,239,293,349,43,347,431 %N 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. %C A383743 To obtain a(n), the digits i and j in a(n-1) are chosen among all possible pairs of different digits in a(n-1) so that they produce the smallest prime not yet in the sequence according to the precedence requirement in the definition. Naturally, to obtain a(n+1), the process is repeated but now a different pair of digits k, l in a(n) may be chosen to produce a(n+1). %C A383743 Note that it is enough that there exists a pair of digits i and j in a(n) that satisfy the precedence requirement; not every pair of such digits must satisfy the requirement in the case of multiple occurrences of such digits in a(n) (see examples). %H A383743 Robert Israel, <a href="/A383743/b383743.txt">Table of n, a(n) for n = 1..10000</a> %H A383743 Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a383/A383743.java">Java program</a> (github) %e A383743 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. %e A383743 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). %e A383743 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). %e A383743 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). %p A383743 P:= select(isprime,[seq(i,i=13 .. 1000,2)]): %p A383743 g:= proc(n) local L, R,i,j; %p A383743 L:= convert(n,base,10); %p A383743 R:= select(t -> t[2] <> t[1], {seq(seq([L[i],L[j]],j=1..i-1),i=1..nops(L))}); %p A383743 end proc: %p A383743 R:= 13: r:= 13: Cands:= subsop(1=NULL,P): %p A383743 do qr:= map(t -> [t[2],t[1]],g(r)): found:= false; %p A383743 for i from 1 to nops(Cands) do %p A383743 if g(Cands[i]) intersect qr <> {} then %p A383743 r:= Cands[i]; R:= R,r; Cands:= subsop(i=NULL,Cands); found:= true; break %p A383743 fi %p A383743 od; %p A383743 until not found: %p A383743 R; # _Robert Israel_, Jun 09 2025 %Y A383743 Cf. A107801, A381130. %K A383743 nonn,base %O A383743 1,1 %A A383743 _Enrique Navarrete_, May 08 2025