login
A122592
a(n) = - a(n-1) + a(n-3) + (a(n-1) - a(n-2))^2 + (a(n-2) - a(n-3))^2.
4
1, 1, 1, 0, 2, 4, 4, 2, 6, 18, 144, 15882, 247684656, 61339821614663208, 3762573685332838515711641628032454, 14156960737559137644661747812427568488753428461913274274176986277422
OFFSET
1,5
LINKS
FORMULA
a(n) = a(n-1) - 2*a(n-1) + a(n-3) + (a(n-1) - a(n-2))^2 + (a(n-2) - a(n-3))^2, with a(1) = a(2) = a(3) = 1.
MATHEMATICA
(* First program *)
a[n_]:= a[n]= If[n<4, 1, -a[n-1] +a[n-3] +(a[n-1] -a[n-2])^2 +(a[n-2] -a[n-3])^2];
Table[a[n], {n, 20}]
(* Second program *)
RecurrenceTable[{a[1]==a[2]==a[3]==1, a[n]==-a[n-1]+a[n-3]+(a[n-2]-a[n-1])^2+(a[n-2]-a[n-3])^2}, a, {n, 20}] (* Harvey P. Dale, Dec 18 2012 *)
PROG
(Magma)
function a(n) // a = A122592
if n lt 4 then return 1;
else return -a(n-1) +a(n-3) +(a(n-1) -a(n-2))^2 +(a(n-2) -a(n-3))^2;
end if; return a; end function;
[a(n): n in [1..18]]; // G. C. Greubel, Nov 29 2021
(Sage)
@CachedFunction
def a(n): return 1 if (n<4) else -a(n-1) +a(n-3) +(a(n-1) -a(n-2))^2 +(a(n-2) -a(n-3))^2 # a = A122592
[a(n) for n in (1..18)] # G. C. Greubel, Nov 29 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Sep 19 2006
EXTENSIONS
Edited by N. J. A. Sloane, Sep 21 2006
Definition corrected by Harvey P. Dale, Dec 18 2012
STATUS
approved