OFFSET
1,6
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..17
FORMULA
a(n) = -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
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, 15}]
PROG
(Magma)
function a(n) // a = A122593
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..15]]; // 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 = A122593
[a(n) for n in (1..15)] # G. C. Greubel, Nov 29 2021
CROSSREFS
KEYWORD
sign
AUTHOR
Roger L. Bagula, Sep 19 2006
EXTENSIONS
Edited by N. J. A. Sloane, Sep 21 2006
Recurrence formula corrected by Georg Fischer, Apr 10 2024
STATUS
approved