OFFSET
1,2
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.
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
EXAMPLE
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}.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Mar 13 2007
STATUS
approved