login
A009947
Sequence of nonnegative integers, but insert n/2 after every even number n.
15
0, 0, 1, 2, 1, 3, 4, 2, 5, 6, 3, 7, 8, 4, 9, 10, 5, 11, 12, 6, 13, 14, 7, 15, 16, 8, 17, 18, 9, 19, 20, 10, 21, 22, 11, 23, 24, 12, 25, 26, 13, 27, 28, 14, 29, 30, 15, 31, 32, 16, 33, 34, 17, 35, 36, 18, 37, 38, 19, 39, 40, 20, 41, 42, 21, 43, 44, 22, 45, 46
OFFSET
0,4
COMMENTS
Coefficients in expansion of e/3 = Sum_{n>=1} a(n)/n!, using greedy algorithm.
Numerators of Peirce sequence of order 2.
REFERENCES
R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics, Addison-Wesley, Reading, MA, 2nd ed. 1998, p. 151.
FORMULA
G.f.: x^2*(x^3+x^2+2*x+1) / ((x-1)^2*(x^2+x+1)^2). - Colin Barker, Aug 31 2013
a(n) = (n^2-n+floor(n/3)*(18*floor(n/3)^2-3*(4*n-7)*floor(n/3)+2*n^2-10*n+7))/2. - Luce ETIENNE, Mar 29 2017
Sum_{n>=2} (-1)^n/a(n) = Pi/4 + log(2)/2. - Amiram Eldar, Jan 11 2023
MAPLE
A009947 := proc(a, n) local i, b, c; b := a; c := [ floor(b) ]; for i from 1 to n-1 do b := b-c[ i ]/i!; c := [ op(c), floor(b*(i+1)!) ]; od; c; end:
MATHEMATICA
Flatten[Table[If[EvenQ[n], {n, n/2}, n], {n, 0, 40}]] (* Harvey P. Dale, Feb 17 2016 *)
PROG
(Haskell)
a009947 n = a009947_list !! n
a009947_list = concatMap (\x -> [2 * x, x, 2 * x + 1]) [0..]
-- Reinhard Zumkeller, Jul 06 2012
(PARI) a(n)=if(n%3==1, n\3, n\3*2+!!(n%3)) \\ Charles R Greathouse IV, Sep 02 2015
(PARI) concat(vector(2), Vec(x^2*(x^3+x^2+2*x+1) / ((x-1)^2*(x^2+x+1)^2) + O(x^100))) \\ Colin Barker, Mar 29 2017
CROSSREFS
Cf. A071281, A214090 (parity), A001477.
Cf. A166711 (signed).
Sequence in context: A125160 A359027 A366691 * A166711 A026249 A130527
KEYWORD
nonn,easy
AUTHOR
STATUS
approved