login
a(0) = 0. If n is odd, a(n) = a(n-1) + n, otherwise a(n) = a(n-1) * n.
9

%I #40 Feb 13 2022 10:55:56

%S 0,1,2,5,20,25,150,157,1256,1265,12650,12661,151932,151945,2127230,

%T 2127245,34035920,34035937,612646866,612646885,12252937700,

%U 12252937721,269564629862,269564629885,6469551117240,6469551117265,168208329048890

%N a(0) = 0. If n is odd, a(n) = a(n-1) + n, otherwise a(n) = a(n-1) * n.

%H William Boyles, <a href="/A077138/b077138.txt">Table of n, a(n) for n = 0..1000</a> [Terms 0 through 26 were computed by Amarnath Murthy; terms 27 through 1000 were computed by William Boyles, Nov 27 2016]

%F a(0) = 0, a(2n) = 2n*a(2n-1) and a(2n+1) = a(2n) +(2n +1).

%t a = 0; Table[If[OddQ[n], a = n + a, a = n*a], {n, 0, 30}] (* _T. D. Noe_, Feb 26 2013 *)

%t nxt[{n_,a_}]:={n+1,If[EvenQ[n],a+n+1,a(n+1)]}; NestList[nxt,{0,0},30][[All,2]] (* _Harvey P. Dale_, Feb 13 2022 *)

%o (PARI) a(n)=if(n<0,0,if(n%2,n+a(n-1),n*a(n-1)))

%o (Python)

%o a=0

%o for n in range(1, 33):

%o print(a, end=', ')

%o if n&1:

%o a += n

%o else:

%o a *= n

%Y Cf. A047904, A047905, A222559.

%K nonn,easy

%O 0,3

%A _Amarnath Murthy_, Oct 30 2002

%E Name improved by _T. D. Noe_, Feb 26 2013