login
A123945
A version of F. K. Hwang's sequence in {3*k, 3*k+1, 3*k+2}.
1
0, 1, 1, 2, 6, 6, 5, 13, 14, 11, 27, 29, 23, 55, 60, 48, 112, 122, 97, 225, 245, 195, 451, 492, 392, 904, 986, 785, 1809, 1972, 1571, 3619, 3946, 3144, 7240, 7894, 6289, 14481, 15789, 12579, 28963, 31580, 25160, 57928, 63161, 50321, 115857, 126323, 100643, 231715, 252648, 201288
OFFSET
0,4
LINKS
F. R. K. Chung, Problem 13
Donald E. Knuth, Exercise 14 (F. K. Hwang)
FORMULA
a(3*n) = floor((43/28)*2^n) - 1,
a(3*n+1) = a(3*n) + 2^(n+1),
a(3*n+2) = floor((17/7)*2^n - 6/7).
MATHEMATICA
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 *)
PROG
(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 ) ) );
vector(50, n, n--; a(n) ) \\ G. C. Greubel and Michel Marcus, Aug 06 2019
(Magma)
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) >;
[a(n): n in [0..50]]; // G. C. Greubel, Aug 06 2019
(Sage)
def a(n):
if (n<4): return fibonacci(n)
elif (mod(n, 3)==0): return floor((43/28)*2^floor(n/3)) - 1
elif (mod(n, 3)==1): return a(n-1) +2*2^floor((n-1)/3)
else: return floor((17/7)*2^(n/3) - 6/7)
[a(n) for n in (0..50)] # G. C. Greubel, Aug 06 2019
CROSSREFS
Sequence in context: A350031 A065486 A069806 * A291793 A284121 A198102
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Oct 25 2006
EXTENSIONS
Terms a(31) onward added by G. C. Greubel, Aug 06 2019
STATUS
approved