login
a(n) = (-1)^n * n * a(n-1) - 1, with a(0)=0.
3

%I #10 Sep 08 2022 08:45:52

%S 0,-1,-3,8,31,-156,-937,6558,52463,-472168,-4721681,51938490,

%T 623261879,-8102404428,-113433661993,1701504929894,27224078878303,

%U -462809340931152,-8330568136760737,158280794598454002

%N a(n) = (-1)^n * n * a(n-1) - 1, with a(0)=0.

%C The sequence alternates in the sign and in the odd-even parity.

%H G. C. Greubel, <a href="/A176304/b176304.txt">Table of n, a(n) for n = 0..445</a>

%p a(n):=`if`(n=0, 0, (-1)^n*n*a(n-1) -1); seq(a(n), n=0..20); # _G. C. Greubel_, Nov 26 2019

%t a[n_]:= a[n] = If[n==0, 0, (-1)^n*n*a[n-1] -1]; Table[a[n], {n, 0, 20}]

%o (PARI) a(n) = if(n==0, 0, (-1)^n*n*a(n-1) -1); \\ _G. C. Greubel_, Nov 26 2019

%o (Magma)

%o function a(n)

%o if n eq 0 then return 0;

%o else return (-1)^n*n*a(n-1) -1;

%o end if; return a; end function;

%o [a(n): n in [0..20]]; // _G. C. Greubel_, Nov 26 2019

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n==0): return 0

%o else: return (-1)^n*n*a(n-1) -1

%o [a(n) for n in (0..20)] # _G. C. Greubel_, Nov 26 2019

%K sign,easy

%O 0,3

%A _Roger L. Bagula_, Apr 14 2010