OFFSET
1,3
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
E. Berlekamp and J. Buhler, Puzzle 6, Puzzles column, Emissary Fall (2011) 9.
Steve Butler, Ron Graham, and Richard Stong, Collapsing numbers in bases 2, 3, and beyond, in The Proceedings of the Gathering for Gardner 10 (2012).
Steve Butler, Ron Graham, and Richard Strong, Inserting plus signs and adding, Amer. Math. Monthly 123 (3) (2016), 274-279.
EXAMPLE
For n = 13, we can partition its binary representation as follows (showing partition and sum of terms): (1101):13, (1)(101):6, (11)(01):4, (110)(1):7, (1)(1)(01):3, (1)(10)(1):4, (11)(0)(1):4, (1)(1)(0)(1):3. Thus the smallest power of 2 is 4.
MAPLE
g:= proc(n) option remember; local i, R;
R:= {n};
for i from 1 to ilog2(n) do
R:= R union (procname(floor(n/2^i)) +~ (n mod 2^i));
od;
R;
end proc:
g(0):= {0}: g(1):= {1}:
f:= proc(n) local x;
for x in sort(convert(g(n), list)) do
if x = 2^padic:-ordp(x, 2) then
return x
fi
od;
-1
end proc:
map(f, [$1..100]); # Robert Israel, Jan 30 2026
MATHEMATICA
sumInt[LL_] := Total[(FromDigits[#1, 2] & ) /@ LL];
BGS[{{1}, {1}, {1}, {1}, {1}}] = {{1}, {1, 1, 1, 1}};
BGS[{{1}, {1}, {1}, {1}, {1}, {0}}] = {{1, 1}, {1, 1}, {1, 0}};
BGS[L_ /; Total[Flatten[L]] == 5] := (p =
Position[Range[Length[L]-2], x_Integer /; L[[x+{0, 1}]]==={{1}, {0}}, {1}, 1][[1, 1]];
Join[L[[1 ;; p - 1]], {L[[p + {0, 1, 2}, 1]]},
L[[p + 3 ;; Length[L]]]]);
tripleMerge[L_, pow_]:=(
p=Position[Range[Length[L]-2], x_Integer/; L[[x]]==={1}, {1}, 1];
If[p === {}, L,
p = p[[1, 1]]; J = Join[L[[1 ;; p - 1]], {L[[p + {0, 1, 2}, 1]]},
L[[p+3;; Length[L]]]]; If[sumInt[J] <= pow, J, L]]);
doubleMerge[L_, pow_] := (
p=Position[Range[Length[L]-1], x_Integer/; L[[x]] === {1}, {1}, 1];
If[p === {}, L, p = p[[1, 1]];
J = Join[L[[1 ;; p - 1]], {L[[p + {0, 1}, 1]]},
L[[p + 2 ;; Length[L]]]]; If[sumInt[J] <= pow, J, L]]);
BGS[L_ /; Total[Flatten[L]] != 5] := (old = L;
pow = 2^Ceiling[Log2[Total[Flatten[L]]]];
While[new = tripleMerge[old, pow]; new =!= old, old = new];
While[new = doubleMerge[old, pow]; new =!= old, old = new];
new);
sumInt[BGS[List /@ IntegerDigits[#, 2]]] & /@ Range[86] (* Stan Wagon, Jan 25 2026 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jeffrey Shallit, Nov 04 2018
STATUS
approved
