login
a(n) = n!*(1/1 + 1/2 + ... + 1/n) - (1! + 2! + ... + n!).
2

%I #20 Sep 08 2022 08:45:45

%S 0,0,0,2,17,121,891,7155,63351,617463,6590727,76589127,963486567,

%T 13052781927,189537379047,2937560365287,48409889869287,

%U 845393769958887,15596602532173287,303139660882458087,6191620542649779687

%N a(n) = n!*(1/1 + 1/2 + ... + 1/n) - (1! + 2! + ... + n!).

%C a(n) is the number of cycles that cannot be written in the form (j,j+1,j+2,...), in all permutations of {1,2,...,n}. Example: a(3)=2 because in (1)(2)(3), (1)(23), (12)(3), (13)(2), (123), (132) we have 0+0+0+1+0+1 = 2 such cycles.

%H Robert Israel, <a href="/A161128/b161128.txt">Table of n, a(n) for n = 0..449</a>

%F a(n) = A000254(n) - A007489(n).

%F (n+1)*n*a(n+3) - n*(2*n^2+8*n+7)*a(n+2) + (n+2)*(n^3+5*n^2+6*n+1)*a(n+1) - (n+1)^3*(n+2)*a(n) = 0. - _Robert Israel_, Apr 11 2018

%p a := proc (n) options operator, arrow: factorial(n)*harmonic(n)-add(factorial(j), j = 1 .. n) end proc: seq(a(n), n = 0 .. 22);

%p # Alternative:

%p f:= gfun:-rectoproc({(n+1)*n*a(n+3) - n*(2*n^2+8*n+7)*a(n+2) + (n+2)*(n^3+5*n^2+6*n+1)*a(n+1) - (n+1)^3*(n+2)*a(n), a(0)=0, a(1)=0, a(2)=0, a(3)=2},a(n),remember):

%p map(f, [$0..30]); # _Robert Israel_, Apr 11 2018

%t Table[n!*HarmonicNumber[n] - Sum[k!, {k,1,n}], {n,0,30}] (* _G. C. Greubel_, Oct 14 2018 *)

%o (PARI) a(n) = n!*sum(k=1, n, 1/k) - sum(k=1, n, k!); \\ _Michel Marcus_, Apr 11 2018

%o (Magma) [0] cat [Factorial(n)*HarmonicNumber(n) - (&+[Factorial(k): k in [1..n]]): n in [1..30]]; // _G. C. Greubel_, Oct 14 2018

%Y Cf. A000254, A007489.

%K nonn

%O 0,4

%A _Emeric Deutsch_, Jul 14 2009