OFFSET
0,3
LINKS
Wikipedia, Permutation
EXAMPLE
a(3) = 3: 123, 132, 213.
a(4) = 5: 1234, 1243, 1324, 2134, 2143.
a(5) = 13: 12345, 12354, 12435, 13245, 13254, 21345, 21354, 21435, 23451, 51234, 52341, 52431, 53241.
MAPLE
b:= proc(s) option remember; (n-> `if`(n=0, 1, add(`if`(
issqr(abs(n-j)), b(s minus {j}), 0), j=s)))(nops(s))
end:
a:= n-> b({$1..n}):
seq(a(n), n=0..16);
MATHEMATICA
b[s_] := b[s] = Function[n, If[n == 0, 1, Sum[If[IntegerQ@Sqrt[Abs[n-j]], b[s ~Complement~ {j}], 0], {j, s}]]][Length[s]];
a[n_] := b[Range[n]];
a /@ Range[0, 16] (* Jean-François Alcover, Apr 23 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Feb 25 2019
STATUS
approved