A298208 a(n) is the smallest positive integer not yet in the sequence that shares a digit with a(n-2) and shares no digit with a(n-1); a(1) = 0, a(2) = 1.
0, 1, 20, 11, 2, 10, 22, 13, 24, 3, 4, 23, 14, 25, 16, 5, 6, 15, 26, 17, 28, 7, 8, 27, 18, 29, 31, 9, 12, 39, 21, 30, 19, 32, 41, 33, 40, 35, 42, 36, 44, 37, 45, 38, 46, 53, 47, 50, 34, 51, 43, 52, 48, 55, 49, 56, 74, 58, 64, 57, 60, 54, 61, 59, 62, 75, 63, 70
Offset: 1
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Programs
-
Maple
N:= 1000: # to get all terms before the first term > N a[1] := 0: a[2] := 1: first := 2: Next := Array(2 .. N, i -> i+1): Prev := Array(2 .. N, i -> i-1): Prev[2] := 0: for n from 0 to N do digs[n] := convert(convert(n, base, 10), set) od: for n from 3 do D1 := digs[a[n-1]]; D2 := digs[a[n-2]]; t := first; while digs[t] intersect D2 = {} or digs[t] intersect D1 <> {} do t := Next[t]; if t > N then break fi od; if t > N then break fi; a[n] := t; if Prev[t] = 0 then first := Next[t] else Next[Prev[t]] := Next[t] fi; if Next[t] <= N then Prev[Next[t]] := Prev[t] fi od: seq(a[i],i=1..n-1); # Robert Israel, Feb 09 2018
-
Mathematica
f[s_List] := Block[{a = Union@ IntegerDigits@ s[[-2]], b = Union@ IntegerDigits@ s[[-1]], k = 2}, While[id = Union@ IntegerDigits@ k; MemberQ[s, k] || Intersection[a, id] == {} || Intersection[b, id] != {}, k++]; Append[s, k]]; Nest[f, {0, 1}, 66] (* Robert G. Wilson v, Feb 09 2018 *)
Comments