login
A203075
Write n as a sum of distinct terms from A203074; if there is more than one way, choose the smallest binary number.
2
0, 1, 10, 11, 101, 110, 111, 1010, 1011, 1101, 1110, 1111, 10001, 10010, 10011, 10101, 10110, 10111, 11010, 11011, 11101, 11110, 11111, 100111, 101010, 101011, 101101, 101110, 101111, 110001, 110010, 110011, 110101, 110110, 110111, 111010, 111011
OFFSET
0,3
COMMENTS
a(n) is a binary vector for selecting terms from the complete sequence, A203074 that when summed gives n. It uses a miserly algorithm that chooses the smallest binary vector if there are multiple solutions. Somewhat similar to, although different from, A014417 and A104326.
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 A203074 = n, where x is the inner product and the binary vector a(n) is in ascending powers of 2 with infinite trailing zeros.
EXAMPLE
5 can be written as 5, i.e., 1000, or as 3+2, i.e., 110, and we choose the smaller.
18 can be written as 17+1, i.e., 100001, or as 11+5+2, i.e., 11010, and again we choose the smaller.
MATHEMATICA
nextprime[n_Integer] := (k=n+1; While[!PrimeQ[k], k++]; k); aprime[m_Integer] := (If[m==0, 1, nextprime[2^(m-1)]]); seqtable[l_] := (stable=Table[aprime[j], {j, 0, l}]; stable); inttable[p_] := (itable=Reverse[IntegerDigits[p, 2]]; itable); h=1; otable={0}; ttable={}; While[h<100, (inttable[h]; seqtable[Length[itable]-1]; test=itable.stable; If[!MemberQ[ttable, test], AppendTo[otable, h], Null]; AppendTo[ttable, test]; h++)]; IntegerString[otable, 2]
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved