OFFSET
1,2
COMMENTS
a(n) = 2 iff n is prime with a(p) = card{ 1|2|3|...|p-1|p, 123...p } = 2. - Bernard Schott, May 16 2019
LINKS
FORMULA
a(n) = Sum_{d divides n} (n!/(d!*((n/d)!)^d)).
E.g.f.: Sum_{k >= 1} (exp(x^k/k!)-1).
EXAMPLE
a(4) = card{ 1|2|3|4, 12|34, 14|23, 13|24, 1234 } = 5.
From Gus Wiseman, Jul 12 2019: (Start)
The a(6) = 27 set partitions:
{{1}{2}{3}{4}{5}{6}} {{12}{34}{56}} {{123}{456}} {{123456}}
{{12}{35}{46}} {{124}{356}}
{{12}{36}{45}} {{125}{346}}
{{13}{24}{56}} {{126}{345}}
{{13}{25}{46}} {{134}{256}}
{{13}{26}{45}} {{135}{246}}
{{14}{23}{56}} {{136}{245}}
{{14}{25}{36}} {{145}{236}}
{{14}{26}{35}} {{146}{235}}
{{15}{23}{46}} {{156}{234}}
{{15}{24}{36}}
{{15}{26}{34}}
{{16}{23}{45}}
{{16}{24}{35}}
{{16}{25}{34}}
(End)
MAPLE
A038041 := proc(n) local d;
add(n!/(d!*(n/d)!^d), d = numtheory[divisors](n)) end:
seq(A038041(n), n = 1..29); # Peter Luschny, Apr 16 2011
MATHEMATICA
a[n_] := Block[{d = Divisors@ n}, Plus @@ (n!/(#! (n/#)!^#) & /@ d)]; Array[a, 29] (* Robert G. Wilson v, Apr 16 2011 *)
Table[Sum[n!/((n/d)!*(d!)^(n/d)), {d, Divisors[n]}], {n, 1, 31}] (* Emanuele Munarini, Jan 30 2014 *)
sps[{}]:={{}}; sps[set:{i_, ___}]:=Join@@Function[s, Prepend[#, s]&/@sps[Complement[set, s]]]/@Cases[Subsets[set], {i, ___}];
Table[Length[Select[sps[Range[n]], SameQ@@Length/@#&]], {n, 0, 8}] (* Gus Wiseman, Jul 12 2019 *)
PROG
(PARI) /* compare to A061095 */
mnom(v)=
/* Multinomial coefficient s! / prod(j=1, n, v[j]!) where
s= sum(j=1, n, v[j]) and n is the number of elements in v[]. */
sum(j=1, #v, v[j])! / prod(j=1, #v, v[j]!)
A038041(n)={local(r=0); fordiv(n, d, r+=mnom(vector(d, j, n/d))/d!); return(r); }
vector(33, n, A038041(n)) /* Joerg Arndt, Apr 16 2011 */
(Maxima) a(n):= lsum(n!/((n/d)!*(d!)^(n/d)), d, listify(divisors(n)));
makelist(a(n), n, 1, 40); /* Emanuele Munarini, Feb 03 2014 */
(Python)
import math
def a(n):
count = 0
for k in range(1, n + 1):
if n % k == 0:
count += math.factorial(n) // (math.factorial(k) ** (n // k) * math.factorial(n // k))
return count # Paul Muljadi, Sep 25 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman
STATUS
approved