cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A009947 Sequence of nonnegative integers, but insert n/2 after every even number n.

Original entry on oeis.org

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

Views

Author

Keywords

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.

Crossrefs

Cf. A071281, A214090 (parity), A001477.
Cf. A166711 (signed).

Programs

  • Haskell
    a009947 n = a009947_list !! n
    a009947_list = concatMap (\x -> [2 * x, x, 2 * x + 1]) [0..]
    -- Reinhard Zumkeller, Jul 06 2012
    
  • 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 *)
  • 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

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