login
A355807
a(n) is the number at the apex of a triangle whose base contains the distinct powers of 2 summing to n (in ascending order), and each number in a higher row is the absolute difference of the two numbers directly below it; a(0) = 0.
5
0, 1, 2, 1, 4, 3, 2, 1, 8, 7, 6, 5, 4, 1, 2, 1, 16, 15, 14, 13, 12, 9, 10, 9, 8, 1, 2, 3, 4, 3, 2, 1, 32, 31, 30, 29, 28, 25, 26, 25, 24, 17, 18, 13, 20, 19, 18, 17, 16, 1, 2, 11, 4, 5, 6, 3, 8, 7, 6, 3, 4, 1, 2, 1, 64, 63, 62, 61, 60, 57, 58, 57, 56, 49, 50
OFFSET
0,3
COMMENTS
This sequence has similarities with A334387.
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, abs(b[k+1]-b[k]))); if (#b, b[1], 0) }
CROSSREFS
See A355808, A355809, A355810 and A355811 for other variants.
Sequence in context: A281589 A302436 A283167 * A355808 A080079 A341707
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jul 18 2022
STATUS
approved