login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A078446
a(1)=a(2)=1; a(n)=a(n-2)/2 if a(n-2) is even, a(n)=a(n-1)+a(n-2) otherwise.
9
1, 1, 2, 3, 1, 4, 5, 2, 7, 1, 8, 9, 4, 13, 2, 15, 1, 16, 17, 8, 25, 4, 29, 2, 31, 1, 32, 33, 16, 49, 8, 57, 4, 61, 2, 63, 1, 64, 65, 32, 97, 16, 113, 8, 121, 4, 125, 2, 127, 1, 128, 129, 64, 193, 32, 225, 16, 241, 8, 249, 4, 253, 2, 255, 1, 256, 257, 128, 385, 64, 449, 32, 481, 16, 497
OFFSET
1,3
COMMENTS
The following sequences all have the same parity: A004737, A006590, A027052, A071028, A071797, A078358, A078446. - Jeremy Gardiner, Mar 16 2003
LINKS
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
Sequence in context: A328456 A253887 A026370 * A357241 A055447 A055448
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Dec 31 2002
STATUS
approved