OFFSET
1,2
COMMENTS
Sum (number of cycles) over all n! permutations of [1..n] gives A000254.
a(n) equals -1 times the coefficient of x of the characteristic polynomial of the n X n matrix whose (i,j)-entry is equal to i+1 if i=j, and is equal to 1 otherwise. [John M. Campbell, May 24 2011]
LINKS
N. J. A. Sloane and Alois P. Heinz, Table of n, a(n) for n = 1..450 (first 30 terms from N. J. A. Sloane)
FORMULA
a(n) = (-1)^(n+1)*(Stirling1(n+1,2)-2*Stirling1(n+1,3)). - Vladeta Jovovic, Jul 22 2009
a(n) = n!*(H(n)+H(n)^2-H2(n)), where H(n)=sum(k=1..n,1/k), H2(n)=sum(k=1..n,1/k^2). - Vladimir Reshetnikov, Oct 20 2015
E.g.f.: (log(1-x)^2-log(1-x))/(1-x). - Vladimir Reshetnikov, Oct 20 2015
a(n) = Sum_{k=0..n} |Stirling1(n,k)|*k^2. - Peter Luschny, Jan 14 2020
MAPLE
with(combinat): with(numtheory):
M:=30;
for n from 1 to M do
p:=partition(n); s:=0:
for k from 1 to nops(p) do
# get next partition of n
# convert partition to list of sizes of parts
q:=convert(p[k], multiset);
for i from 1 to n do a(i):=0: od:
for i from 1 to nops(q) do a(q[i][1]):=q[i][2]: od:
# get number of parts:
nump := add(a(i), i=1..n);
# get multiplicity:
c:=1: for i from 1 to n do c:=c*a(i)!*i^a(i): od:
prop:=nump^2;
s:=s + (n!/c)*prop;
od;
lprint(n, s);
A[n]:=s;
od:
[seq(A[n], n=1..M)];
# Alternatively after Reshetnikov:
a := n -> n!*(add(1/k, k=1..n)^2 + add(1/k-1/k^2, k=1..n)):
seq(a(n), n=1..19); # Peter Luschny, Oct 21 2015
MATHEMATICA
Table[-Coefficient[CharacteristicPolynomial[ Array[KroneckerDelta[#1, #2]((((#1+1)))-1)+1&, {n, n}], x], x], {n, 1, 10}] (* John M. Campbell, May 24 2011 *)
Table[n! (HarmonicNumber[n] + HarmonicNumber[n]^2 - HarmonicNumber[n, 2]), {n, 1, 20}] (* Vladimir Reshetnikov, Oct 20 2015 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Jul 22 2009
STATUS
approved