login
A123946
a(3n) = floor(43*2^n/28) - 1, a(3n+1) = a(3n) + 3*2^(n-3), a(3n+2) = floor(17*2^n/7 - 6/7) for n>=3.
1
1, 1, 2, 2, 3, 4, 5, 7, 9, 11, 14, 18, 23, 29, 38, 48, 60, 76, 97, 121, 154, 195, 243, 310, 392, 488, 620, 785, 977, 1242, 1571, 1955, 2486, 3144, 3912, 4972, 6289, 7825, 9946, 12579, 15651, 19894, 25160, 31304, 39788, 50321, 62609, 79578, 100643, 125219
OFFSET
0,3
COMMENTS
Theorem 3 of Dubickas implies that infinitely many terms of this sequence are composite. - Charles R Greathouse IV, Feb 04 2016
REFERENCES
Artūras Dubickas, Prime and composite integers close to powers of a number, Monatsh. Math. 158:3 (2009), pp. 271-284.
D. E. Knuth, The Art of Computer Programming Vol. 3, Addison-Wesley, Reading, MA, 1998, p. 206, Exercise 14 (F. K. Hwang).
LINKS
R. L. Graham, Exercise 14
FORMULA
Empirical g.f.: (2*x^18-x^17-x^16+x^15+x^14-x^13+2*x^12-x^11-x^9+x^7+x^4-x^3+x^2+1) / ((x-1)*(2*x^3-1)*(x^6+x^3+1)). - Colin Barker, Nov 21 2015
MAPLE
a[0]:=1: a[1]:=1: a[2]:=2: a[3]:=2: a[4]:=3: a[5]:=4: a[6]:=5: a[7]:=7: a[8]:=9: for n from 3 to 19 do a[3*n]:=floor(43*2^n/28)-1: a[3*n+1]:=a[3*n]+3*2^(n-3): a[3*n+2]:=floor(17*2^n/7-6/7) od: seq(a[n], n=0..59);
MATHEMATICA
a[n_]:= a[n] = With[{k = Floor[n/3]}, If[Mod[n, 3]==0, Floor[(43/28)*2^k] - 1, If[Mod[n, 3]==1, Floor[(43/28)*2^k] -1 +3*2^(k-3), Floor[(17/7)*2^k - 6/7]]]]; Join[{1, 1, 2, 2, 3, 4, 5, 7, 9}, Table[a[n], {n, 9, 50}]] (* G. C. Greubel, Aug 05 2019 *)
PROG
(PARI) vector(50, n, n--; k=n\3; if(n<9, if(n%3==0, 3*2^k\2-(k>0), if(n%3==2, 2*(17*2^k\14)+(k==2), 53*2^k\28-(k>2))), if(n%3==0, floor(43*2^k/28)-1, if(n%3==1, floor(43*2^k/28)-1+3*2^(k-3), floor(17*2^k/7-6/7))))) \\ Altug Alkan, Nov 22 2015
(Magma)
a:= func< n | (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/3)) -1 +3*2^(Floor(n/3)-3) else Floor((17/7)*2^Floor(n/3) - 6/7) >;
[1, 1, 2, 2, 3, 4, 5, 7, 9] cat [a(n): n in [9..50]]; // G. C. Greubel, Aug 05 2019
(Sage)
def a(n):
if (mod(n, 3)==0): return floor((43/28)*2^floor(n/3)) - 1
elif (mod(n, 3)==1): return floor((43/28)*2^floor(n/3)) -1 +3*2^(floor(n/3)-3)
else: return floor((17/7)*2^floor(n/3) - 6/7)
[1, 1, 2, 2, 3, 4, 5, 7, 9]+[a(n) for n in (9..50)] # G. C. Greubel, Aug 05 2019
(GAP)
a:= function(n)
if (n mod 3 =0) then return Int((43/28)*2^Int(n/3)) - 1;
elif (n mod 3 =1) then return Int((43/28)*2^Int(n/3)) -1 +3*2^(Int(n/3)-3);
else return Int((17/7)*2^Int(n/3) - 6/7);
fi;
end;
Concatenation([1, 1, 2, 2, 3, 4, 5, 7, 9], List([9..50], n-> a(n) )); # G. C. Greubel, Aug 05 2019
CROSSREFS
Sequence in context: A052816 A122130 A003073 * A002569 A129528 A364159
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Oct 25 2006
EXTENSIONS
Edited by N. J. A. Sloane, Nov 07 2006
STATUS
approved