OFFSET
0,7
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..900
FORMULA
a(0) = 0; a(1) = 1; a(2*n) = n*a(2*n-1) + a(2*n-2); a(2*n+1) = -a(2*n) + a(2*n-1).
From Mark van Hoeij, Jul 15 2022: (Start)
a(2*n+1) = -(-1)^n * A058797(n-2).
MAPLE
a:= proc(n) option remember;
if n<2 then n
elif (n mod 2)=0 then (n/2)*a(n-1) +a(n-2)
else -a(n-1) +a(n-2)
fi; end:
seq(a(n), n=0..40); # G. C. Greubel, Dec 05 2019
MATHEMATICA
a[n_]:= a[n]= If[n<2, n, If[EvenQ[n], (n/2)*a[n-1] +a[n-2], -a[n-1] +a[n-2]]]; Table[a[n], {n, 0, 40}] (* G. C. Greubel, Dec 05 2019 *)
PROG
(PARI) a(n) = if(n<2, n, if(Mod(n, 2)==0, (n/2)*a(n-1) +a(n-2), -a(n-1) +a(n-2) )); \\ G. C. Greubel, Dec 05 2019
(Sage)
@CachedFunction
def a(n):
if (n<2): return n
elif (mod(n, 2) ==0): return (n/2)*a(n-1) +a(n-2)
else: return -a(n-1) +a(n-2)
[a(n) for n in (0..40)] # G. C. Greubel, Dec 05 2019
(GAP)
a:= function(n)
if n<2 then return n;
elif (n mod 2)=0 then return (n/2)*a(n-1) +a(n-2);
else return -a(n-1) +a(n-2);
fi; end;
List([0..20], n-> a(n) ); # G. C. Greubel, Dec 05 2019
CROSSREFS
KEYWORD
sign,frac,easy
AUTHOR
Aleksandar Petojevic, Sep 05 2000
EXTENSIONS
More terms from James A. Sellers, Sep 06 2000 and from Larry Reeves (larryr(AT)acm.org), Sep 07 2000
STATUS
approved