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.

A126606 Fixed point of transformation of the seed sequence {0,2}.

Original entry on oeis.org

0, 2, 2, 4, 2, 6, 4, 6, 2, 8, 6, 10, 4, 10, 6, 8, 2, 10, 8, 14, 6, 16, 10, 14, 4, 14, 10, 16, 6, 14, 8, 10, 2, 12, 10, 18, 8, 22, 14, 20, 6, 22, 16, 26, 10, 24, 14, 18, 4, 18, 14, 24, 10, 26, 16, 22, 6, 20, 14, 22, 8, 18, 10, 12, 2, 14, 12, 22, 10, 28, 18, 26, 8, 30, 22, 36, 14, 34, 20, 26
Offset: 1

Views

Author

Zak Seidov, Mar 13 2007

Keywords

Comments

Start with s={0,2} If sum of two neighbor terms sum=s(i)+s(i+1) is even then insert the sum in between, otherwise insert abs(s(i)-s(i+1)); repeat the procedure.
{s(i),s(i+1)} => {s(i),s(i)+s(i+1), s(i+1)}, if s(i)+s(i+1) is even, otherwise {s(i),s(i+1)} => {s(i), abs(s(i)-s(i+1)), s(i+1)}.
Each row includes the previous one and then continues.
This sequence is analogous to Stern's diatomic series (A002487) but starting with 0,2 instead of 0,1. - Tom Edgar, May 08 2015

Examples

			Triangle begins:
  {0,2},
  {0,2,2},
  {0,2,2,4,2},
  {0,2,2,4,2,6,4,6,2},
  {0,2,2,4,2,6,4,6,2,8,6,10,4,10,6,8,2}.
		

Crossrefs

Cf. A002487.

Programs

  • Mathematica
    s={0,2}; Do[t=s;ti=1; Do[If[EvenQ[su=s[[i]]+s[[i+1]]],t=Insert[t,su,i+ti], t=Insert[t,Abs[s[[i]]-s[[i+1]]],i+ti]];ti++,{i,Length[s]-1}];s=t,{8}];s
    a[1]=0;a[2]=2;a[n_]:=If[EvenQ[n+1],a[(n+1)/2],a[(n)/2]+a[(n+2)/2]];Table[a[n],{n,100}] (* Vincenzo Librandi, May 09 2015 *)
  • Sage
    def A126606(n):
        M = [2, 0]
        for b in n.bits():
            M[b] = M[0] + M[1]
        return M[1]
    print([A126606(n) for n in (0..79)]) # Peter Luschny, Nov 28 2017

Formula

a(n) = 2 * A002487(n - 1). - Reikku Kulon, Oct 05 2008
a(1) = 0, a(2) = 2; for n>0: a(2n+1) = a(n+1) and a(2n) = a(n) + a(n+1). - Tom Edgar, May 08 2015