OFFSET
0,3
LINKS
FORMULA
a(n) <= n with equality iff n = 0 or n is a power of 2.
a(2*n) = 2*a(n).
EXAMPLE
For n = 27:
- we have the following triangle:
-3
5 2
1 6 8
1 2 8 16
- so a(27) = -3.
PROG
(PARI) a(n) = { my (b=vector(hammingweight(n))); for (k=1, #b, n-=b[k]=2^valuation(n, 2)); while (#b>1, b=vector(#b-1, k, b[k+1]-b[k])); if (#b, b[1], 0) }
CROSSREFS
KEYWORD
sign,base
AUTHOR
Rémy Sigrist, Jul 18 2022
STATUS
approved