OFFSET
0,5
LINKS
Wikipedia, Permutation
FORMULA
a(n) = 0 <=> n in {1, 2, 3, 6, 10}.
EXAMPLE
a(4) = 3: 4213, 4231, 4321.
a(5) = 13: 42135, 42153, 42315, 42351, 42513, 42531, 43215, 43251, 43521, 45123, 45213, 45231, 45321.
a(7) = 828: 4213576, 4213675, 4213756, 4213765, ..., 7564213, 7564231, 7564312, 7564321.
a(8) = 6364: 42135768, 42135786, 42135867, 42135876, ..., 78564123, 78564213, 78564231, 78564321.
a(6) = 0 because 6*7/2 = 21 is Fibonacci number.
a(10) = 0 because 10*11/2 = 55 is Fibonacci number.
MAPLE
q:= proc(n) option remember; (t-> issqr(t+4) or issqr(t-4))(5*n^2) end:
b:= proc(s, p) option remember; `if`(s={}, 1, add(
`if`(q(p+j), 0, b(s minus {j}, p+j)), j=s))
end:
a:= n-> b({$1..n}, 0):
seq(a(n), n=0..17);
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, May 02 2026
STATUS
approved
