OFFSET
0,3
COMMENTS
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..8192
FORMULA
a(0) = a(1) = 1, for n>=1: a(2*n) = a(n-1)+a(n) and a(2*n+1) = a(n+1).
EXAMPLE
a(2^n+1) = 2 because a(2) = 2 and a(2*n+1) = a(n+1).
MAPLE
a:= proc(n) local r;
a(n):= `if`(n<2, 1, `if`(irem(n, 2, 'r')=0, a(r-1)+a(r), a(r+1)))
end:
seq(a(n), n=1..100); # Alois P. Heinz, Jul 06 2012
MATHEMATICA
a[0] = a[1] = 1;
a[n_] := a[n] = If[EvenQ[n], a[n/2-1] + a[n/2], a[(n-1)/2+1]];
Array[a, 100, 0] (* Jean-François Alcover, May 31 2019 *)
PROG
(Python)
a = [1]*(77*2)
for n in range(1, 77):
a[2*n ]=a[n-1]+a[n]
a[2*n+1]=a[n+1]
print(str(a[n-1]), end=', ')
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Jul 04 2012
STATUS
approved