OFFSET
0,3
COMMENTS
a(n) is a binary vector for selecting terms from A000124 that when summed give n. It uses the greedy algorithm to select from multiple solutions.
LINKS
Wikipedia, "Complete" sequence. [Wikipedia calls a sequence "complete" (sic) if every positive integer is a sum of distinct terms. This name is extremely misleading and should be avoided. - N. J. A. Sloane, May 20 2023]
FORMULA
a(n) x A000124 = n, where x is the inner product and the binary vector is in ascending powers of 2 with infinite trailing zeros.
EXAMPLE
14 can be written as 7+4+2+1, i.e., 1111, or as 11+2+1, i.e., 10011, and the latter is chosen because it uses the greedy algorithm for selection.
MATHEMATICA
complete[m_Integer] := (m(m+1)/2+1); gentable[n_Integer] := (m=n; ptable={0}; While[m!=0, (i=0; While[complete[i]<=m&&ptable[[i+1]]!=1, (AppendTo[ptable, 0]; i++)]; ptable[[i]]=1; m=m-complete[i-1])]; ptable); decimal[n_Integer] := (gentable[n]; Sum[2^(k-1)*ptable[[k]], {k, 1, Length[ptable]}]); Table[IntegerString[decimal[s], 2], {s, 0, 100}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Frank M Jackson, Jan 09 2012
EXTENSIONS
Edited by N. J. A. Sloane, May 20 2023
STATUS
approved