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.

A002516 Earliest sequence with a(a(n)) = 2n.

Original entry on oeis.org

0, 3, 6, 2, 12, 7, 4, 10, 24, 11, 14, 18, 8, 15, 20, 26, 48, 19, 22, 34, 28, 23, 36, 42, 16, 27, 30, 50, 40, 31, 52, 58, 96, 35, 38, 66, 44, 39, 68, 74, 56, 43, 46, 82, 72, 47, 84, 90, 32, 51, 54, 98, 60, 55, 100, 106, 80, 59, 62, 114, 104, 63, 116, 122, 192, 67, 70, 130
Offset: 0

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (transpose)
    a002516 n = a002516_list !! n
    a002516_list = 0 : concat (transpose
    [a004767_list, f a002516_list, a017089_list, g $ drop 2 a002516_list])
    where f [z] = []; f (_:z:zs) = 2 * z : f zs
    g [z] = [z]; g (z:_:zs) = 2 * z : g zs
    -- Reinhard Zumkeller, Jun 08 2015
  • Mathematica
    a[0] = 0; a[n_ /; Mod[n, 2] == 0] := a[n] = 2*a[n/2]; a[n_ /; Mod[n, 4] == 1] := n+2; a[n_ /; Mod[n, 4] == 3] := 2(n-2); Table[a[n], {n, 0, 67}] (* Jean-François Alcover, Feb 06 2012, after Henry Bottomley *)
  • PARI
    v2(n)=valuation(n,2)
    a(n)=2^v2(n)*(-1+3/2*n/2^v2(n)-(-3+1/2*n/2^v2(n))*(-1)^((n/2^v2(n)-1)/2))
    
  • PARI
    a(n)=local(t); if(n<1,0,if(n%2==0,2*a(n/2),t=(n-1)/2; 3*t+1/2-(t-5/2)*(-1)^t)) \\ Ralf Stephan, Feb 22 2004
    

Formula

a(4n) = 2*(a(2n)), a(4n+1) = 4n+3, a(4n+2) = 2*(a(2n+1)), a(4n+3) = 8n+2. - Henry Bottomley, Apr 27 2000
From Ralf Stephan, Feb 22 2004: (Start)
a(n) = n + 2*A006519(n) if odd part of n is of form 4k+1, or 2n - 4*A006519(n) otherwise.
a(2n) = 2*a(n), a(2n+1) = 2n + 3 + (2n - 5)*[n mod 2].
G.f.: Sum_{k>=0} 2^k*t(6t^6 + t^4 + 2t^2 + 3)/(1 - t^4)^2, t = x^2^k. (End)