[go: up one dir, main page]

login
A050601 revision #5

A050601
Recursion counts for summation table A003056 with formula a(0,x) = x, a(y,0) = y, a(y,x) = a((y XOR x),2*(y AND x))
2
0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1, 2, 0, 0, 1, 2, 2, 1, 0, 0, 2, 1, 1, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 3, 2, 3, 1, 3, 2, 3, 0, 0, 1, 3, 3, 2, 2, 3, 3, 1, 0, 0, 2, 1, 3, 2, 1, 2, 3, 1, 2, 0, 0, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 0, 0, 3, 2, 3, 1, 3, 1, 3, 1, 3, 2, 3, 0, 0, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 0, 0, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 0
OFFSET
0,12
FORMULA
a(n) -> add2c( (n-((trinv(n)*(trinv(n)-1))/2)), (((trinv(n)-1)*(((1/2)*trinv(n))+1))-n) )
MAPLE
add2c := proc(a, b) option remember; if((0 = a) or (0 = b)) then RETURN(0); else RETURN(1+add_c(XORnos(a, b), 2*ANDnos(a, b))); fi; end;
MATHEMATICA
trinv[n_] := Floor[(1/2)*(Sqrt[8*n + 1] + 1)];
Sum2c[a_, b_] := Sum2c[a, b] = If[0 == a || 0 == b, Return[0], Return[ Sum2c[BitXor[a, b], 2*BitAnd[a, b]] + 1]];
a[n_] := Sum2c[n - (1/2)*trinv[n]*(trinv[n] - 1), (trinv[n] - 1)*(trinv[ n]/2 + 1) - n];
Table[a[n], {n, 0, 120}](* Jean-François Alcover, Mar 07 2016, adapted from Maple *)
CROSSREFS
Cf. A050600, A050602, A003056, A048720 (for the Maple implementation of trinv and XORnos, ANDnos)
Sequence in context: A108803 A348920 A348921 * A101650 A287411 A053796
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, Jun 22 1999
STATUS
editing