A203075 Write n as a sum of distinct terms from A203074; if there is more than one way, choose the smallest binary number.
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
Keywords
Examples
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.
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]
Programs
-
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]
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.
Comments