OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..451
Wikipedia, Permutation
FORMULA
a(n) = Sum_{prime p <= n} A346085(n,p).
a(p) = (p-1)! for prime p.
EXAMPLE
a(2) = 1: (12).
a(3) = 2: (123), (132).
a(4) = 3: (12)(34), (13)(24), (14)(23).
a(5) = 24: (12345), (12354), (12435), (12453), (12534), (12543), (13245), (13254), (13425), (13452), (13524), (13542), (14235), (14253), (14325), (14352), (14523), (14532), (15234), (15243), (15324), (15342), (15423), (15432).
MAPLE
b:= proc(n, g) option remember; `if`(n=0, `if`(isprime(g), 1, 0),
add(b(n-j, igcd(j, g))*(n-1)!/(n-j)!, j=1..n))
end:
a:= n-> b(n, 0):
seq(a(n), n=0..23);
MATHEMATICA
b[n_, g_] := b[n, g] = If[n == 0, If[PrimeQ[g], 1, 0], Sum[b[n - j, GCD[j, g]]*(n - 1)!/(n - j)!, {j, 1, n}]];
a[n_] := b[n, 0];
Table[a[n], {n, 0, 23}] (* Jean-François Alcover, Dec 13 2023, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jan 19 2023
STATUS
approved