login
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

%I #13 Nov 07 2019 19:27:49

%S 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,

%T 49,8,57,4,61,2,63,1,64,65,32,97,16,113,8,121,4,125,2,127,1,128,129,

%U 64,193,32,225,16,241,8,249,4,253,2,255,1,256,257,128,385,64,449,32,481,16,497

%N 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.

%C The following sequences all have the same parity: A004737, A006590, A027052, A071028, A071797, A078358, A078446. - _Jeremy Gardiner_, Mar 16 2003

%H G. C. Greubel, <a href="/A078446/b078446.txt">Table of n, a(n) for n = 1..1000</a>

%F 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

%F Sum(k=1, n^2, a(k)) = 2*(n-2)*2^n + n*(n+1)/2 + 4

%p a:= proc(n) option remember;

%p if n < 3 then 1

%p elif `mod`(procname(n-2), 2) = 0 then procname(n-2)/2

%p else procname(n-1) + procname(n-2)

%p fi

%p end:

%p seq(a(n), n=1..80); # _G. C. Greubel_, Nov 07 2019

%t a[n_]:= a[n]= If[n<3, 1, If[EvenQ[a[n-2]], a[n-2]/2, a[n-1]+a[n-2]]];

%t Table[a[n], {n, 80}] (* _G. C. Greubel_, Nov 07 2019 *)

%o (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

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n<3): return 1

%o elif (a(n-2)%2==0): return a(n-2)/2

%o else: return a(n-1) + a(n-2)

%o [a(n) for n in (1..80)] # _G. C. Greubel_, Nov 07 2019

%K nonn

%O 1,3

%A _Benoit Cloitre_, Dec 31 2002