%I #11 Sep 08 2022 08:45:28
%S 0,1,1,2,6,6,5,13,14,11,27,29,23,55,60,48,112,122,97,225,245,195,451,
%T 492,392,904,986,785,1809,1972,1571,3619,3946,3144,7240,7894,6289,
%U 14481,15789,12579,28963,31580,25160,57928,63161,50321,115857,126323,100643,231715,252648,201288
%N A version of F. K. Hwang's sequence in {3*k, 3*k+1, 3*k+2}.
%H G. C. Greubel, <a href="/A123945/b123945.txt">Table of n, a(n) for n = 0..1000</a>
%H F. R. K. Chung, <a href="http://www.math.ucsd.edu/~fan/ron/images/monster.html">Problem 13</a>
%H Donald E. Knuth, <a href="http://www.math.ucsd.edu/~fan/ron/images/monster.html">Exercise 14 (F. K. Hwang)</a>
%F a(3*n) = floor((43/28)*2^n) - 1,
%F a(3*n+1) = a(3*n) + 2^(n+1),
%F a(3*n+2) = floor((17/7)*2^n - 6/7).
%t a[n_]:= a[n] = If[n<4, Fibonacci[n], If[Mod[n, 3]==0, Floor[(43/28)*2^(n/3)] - 1, If[Mod[n, 3]==1, a[n-1] + 2*2^((n-1)/3), Floor[(17/7)*2^(n/3) - 6/7]]]]; Table[a[n], {n,0,50}] (* modified by _G. C. Greubel_, Aug 06 2019 *)
%o (PARI) a(n) = if(n<4, fibonacci(n), if(n%3==0, 43*2^(n/3)\28 -1, if(n%3==1, a(n-1) + 2*2^((n-1)/3), ((17/7)*2^(n/3) -6/7)\1 ) ) );
%o vector(50, n, n--; a(n) ) \\ _G. C. Greubel_ and _Michel Marcus_, Aug 06 2019
%o (Magma)
%o a:= func< n | n lt 4 select Fibonacci(n) else (n mod 3 eq 0) select Floor((43/28)*2^Floor(n/3)) - 1 else (n mod 3 eq 1) select Floor((43/28)*2^Floor((n-1)/3)) -1 +2^(Floor((n-1)/3)+1) else Floor((17/7)*2^(n/3) - 6/7) >;
%o [a(n): n in [0..50]]; // _G. C. Greubel_, Aug 06 2019
%o (Sage)
%o def a(n):
%o if (n<4): return fibonacci(n)
%o elif (mod(n,3)==0): return floor((43/28)*2^floor(n/3)) - 1
%o elif (mod(n,3)==1): return a(n-1) +2*2^floor((n-1)/3)
%o else: return floor((17/7)*2^(n/3) - 6/7)
%o [a(n) for n in (0..50)] # _G. C. Greubel_, Aug 06 2019
%K nonn
%O 0,4
%A _Roger L. Bagula_, Oct 25 2006
%E Terms a(31) onward added by _G. C. Greubel_, Aug 06 2019