OFFSET
1,2
LINKS
EXAMPLE
a(2) = a(1)^2 + (-1)^2 * 2*(2+1)/2 = 1*1 + 1*3 = 4;
a(3) = a(2)^2 + (-1)^3 * 3*(3+1)/2 = 4*4 - 3*2 = 10;
MATHEMATICA
a[n_]:= a[n]= If[n==1, 1, a[n-1]^2 + (-1)^n*Binomial[n+1, 2]];
Table[a[n], {n, 10}] (* G. C. Greubel, Feb 18 2021 *)
PROG
(Sage)
@CachedFunction
def A118378(n):
if (n==1): return 1
else: return A118378(n-1)^2 +(-1)^n*binomial(n+1, 2)
[A118378(n) for n in (1..10)] # G. C. Greubel, Feb 18 2021
(Magma)
A118378:= func< n | n eq 1 select 1 else Self(n-1)^2 + (-1)^n*Binomial(n+1, 2) >;
[A118378(n): n in [1..10]];
(PARI) a(n) = if (n==1, 1, n--; a(n)^2 - (-1)^n * binomial(n+2, 2)); \\ Michel Marcus, Feb 19 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, May 16 2006
EXTENSIONS
Corrected by Don Reble, Nov 22 2006
STATUS
approved