login
a(n) = (a(n-1) + a(n-3))/2 if (a(n-1)+a(n-3)) is even. Otherwise, a(n)=a(n-1)+a(n-3).
1

%I #28 Feb 25 2023 09:34:17

%S 1,2,1,1,3,2,3,3,5,4,7,6,5,6,6,11,17,23,17,17,20,37,27,47,42,69,58,50,

%T 119,177,227,173,175,201,187,181,191,189,185,188,377,281,469,423,352,

%U 821,622,487,654,638,1125,1779,2417,1771,1775,2096,3867,2821,4917,4392,7213,6065,10457

%N a(n) = (a(n-1) + a(n-3))/2 if (a(n-1)+a(n-3)) is even. Otherwise, a(n)=a(n-1)+a(n-3).

%H Harvey P. Dale, <a href="/A351466/b351466.txt">Table of n, a(n) for n = 1..1000</a>

%p A351466 := proc(n)

%p option remember ;

%p local a;

%p if n <= 2 then

%p n;

%p else

%p a := procname(n-1)+procname(n-3) ;

%p if type(a,'even') then

%p a/2 ;

%p else

%p a ;

%p end if;

%p end if;

%p end proc:

%p seq(A351466(n),n=1..100) ; # _R. J. Mathar_, Jul 05 2022

%t a[1] = a[3] = 1; a[2] = 2; a[n_] := a[n] = If[EvenQ[(s = a[n - 1] + a[n - 3])], s/2, s]; Array[a, 70] (* _Amiram Eldar_, Feb 27 2022 *)

%t nxt[{a_,b_,c_}]:={b,c,If[EvenQ[(a+c)],(a+c)/2,a+c]}; NestList[nxt,{1,2,1},70][[;;,1]] (* _Harvey P. Dale_, Feb 25 2023 *)

%Y Cf. A000930, A214551.

%K nonn,easy

%O 1,2

%A _Jack Braxton_, Feb 11 2022

%E Definition clarified by _Harvey P. Dale_, Feb 25 2023