OFFSET
1,1
COMMENTS
All terms are even.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..1000
E. Angelini, Derangements on the SeqFan list, May 21 2015
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 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Alois P. Heinz, May 21 2015
STATUS
approved