A positive integer can be diluted by inserting a
0 between two bits in its binary expansion. This means that an
n-bit number has
n-1 dilutions, which are not necessarily all distinct.
For example, for
1100 in binary), the dilutions are
11000 = 24 ^ 11000 = 24 ^ 10100 = 20 ^
In this challenge, we're going to be taking the sum of all the dilutions, exclusive of the original number. For
12, taking the sum of
24, 24, 20 results in
68 should be the output for
Given a positive integer
n > 1 as input, output/return the diluted sum as explained above.
in out --- --- 2 4 3 5 7 24 12 68 333 5128 512 9216
- The input and output can be assumed to fit in your language's native integer type.
- The input and output can be given in any convenient format.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.