OFFSET
1,3
COMMENTS
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
FORMULA
a(n^2)=2^n-1; a(n^2+1)=1; a(n^2+2)=2^n; a(n^2+3)=2^n+1; a(n^2+4)=2^(n-1); a(n^2+5)=3*2^n+1 ...; inequality : a(n)/2^sqrt(n) <2
Sum(k=1, n^2, a(k)) = 2*(n-2)*2^n + n*(n+1)/2 + 4
MAPLE
a:= proc(n) option remember;
if n < 3 then 1
elif `mod`(procname(n-2), 2) = 0 then procname(n-2)/2
else procname(n-1) + procname(n-2)
fi
end:
seq(a(n), n=1..80); # G. C. Greubel, Nov 07 2019
MATHEMATICA
a[n_]:= a[n]= If[n<3, 1, If[EvenQ[a[n-2]], a[n-2]/2, a[n-1]+a[n-2]]];
Table[a[n], {n, 80}] (* G. C. Greubel, Nov 07 2019 *)
PROG
(PARI) a(n) = if(n<3, 1, if(a(n-2)%2==0, a(n-2)/2, a(n-1) + a(n-2) )); \\ G. C. Greubel, Nov 07 2019
(Sage)
@CachedFunction
def a(n):
if (n<3): return 1
elif (a(n-2)%2==0): return a(n-2)/2
else: return a(n-1) + a(n-2)
[a(n) for n in (1..80)] # G. C. Greubel, Nov 07 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Dec 31 2002
STATUS
approved