A258137 Absolute first differences of the lexicographically earliest sequence of odd positive integers such that the terms and their absolute first differences are all distinct.
2, 4, 6, 8, 10, 12, 18, 14, 16, 28, 20, 22, 36, 24, 26, 48, 30, 32, 60, 34, 38, 68, 40, 42, 78, 44, 46, 86, 50, 52, 100, 54, 56, 108, 58, 62, 114, 66, 64, 70, 72, 140, 74, 76, 146, 80, 82, 156, 84, 88, 170, 90, 92, 180, 94, 96, 188, 98, 102, 194, 104, 106, 208
Offset: 1
Keywords
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..1000
- E. Angelini, Derangements on the SeqFan list, May 21 2015
Programs
-
Maple
b:= proc() false end: g:= proc(n) option remember; local k; if n=1 then b(1):= true; 1 else g(n-1); for k while b(k) or b(abs(g(n-1)-k)) by 2 do od; b(k), b(abs(g(n-1)-k)):= true$2; k fi end: a:= n-> abs(g(n+1)-g(n)): seq(a(n), n=1..101);
-
Mathematica
b[_] = False; g[n_] := g[n] = Module[{k}, If[n == 1, b[1] = True; 1, g[n-1]; For[k = 1, b[k] || b[Abs[g[n-1] - k]], k += 2]; {b[k], b[Abs[g[n-1] - k]]} = {True, True}; k]]; a[n_] := Abs[g[n+1] - g[n]]; Table[a[n], {n, 1, 101}] (* Jean-François Alcover, Aug 01 2021, after Alois P. Heinz *)
Comments