A303657 a(n) is the least positive integer not yet in the sequence which shares a digit with a(n-2); a(1)=0, a(2)=1.
0, 1, 10, 11, 12, 13, 2, 3, 20, 23, 21, 22, 14, 24, 4, 25, 34, 5, 30, 15, 31, 16, 17, 6, 7, 26, 27, 28, 29, 8, 9, 18, 19, 38, 39, 32, 33, 35, 36, 37, 43, 47, 40, 41, 42, 44, 45, 46, 48, 49, 54, 59, 50, 51, 52, 53, 55, 56, 57, 58, 65, 68, 60, 61, 62, 63, 64, 66
Offset: 1
Examples
a(7)=2 since it is the least positive integer not yet in the sequence which shares a digit with a(5)=12.
Links
- R. J. Cano, Sequencer program in PARI.
Programs
-
Mathematica
f[s_List] := Block[{k = 2, l = Union@ IntegerDigits@ s[[-2]]}, While[MemberQ[s, k] || Intersection[l, IntegerDigits@ k] == {}, k++]; Append[s, k]]; Nest[f, {0, 1}, 70] (* Robert G. Wilson v, Apr 29 2018 *)
-
PARI
Digits(x,b)=if(!x,[0],digits(x,b)); firstTerms(n,{k=2},{b=10})={my(N=b*n);my(s=List(vector(N,u,u-1)),t,x,y);for(m=k+1,n,x=Set(Digits(s[m-k],b));for(i=m,N,y=Set(Digits(s[i],b));if(#setintersect(x,y),t=s[i];listpop(s,i);listinsert(s,t,m);break)));return(Vec(s)[1..n])} a(n)=firstTerms(n)[n]; \\ R. J. Cano, May 05 2018
-
PARI
See Cano link.
Comments