Generate base 2 numbers that add up to $2^n-1$ when left-shifted I am trying to generate such odd numbers $p$ that satisfy
$$\sum_{i=0}^n{2^{ik}p} = 2^m-1$$
for some $m, n, k, p \in \mathbb N$.
In other words, numbers that can be left-shifted (multiplied by $2^k$) so that in base 2, the 1s do not "overlap".
Example 1:
$$
\begin{array}{@{}cr}
   &  10101 \\
+  & 101010 \\
=  & 111111
\end{array}
$$
Example 2:
$$
\begin{array}{@{}cr}
   &   1100110011 \\
+  & 110011001100 \\
=  & 111111111111
\end{array}
$$
Example 3:
$$
\begin{array}{@{}cr}
   &    10001 \\
+  &   100010 \\
+  &  1000100 \\
+  & 10001000 \\
=  & 11111111
\end{array}
$$
Example 4:
$$
\begin{array}{@{}cr}
   &     11000011000011 \\
+  &   1100001100001100 \\
+  & 110000110000110000 \\
=  & 111111111111111111
\end{array}
$$
I am a programmer, so I'd like to end up with a function that takes no input, and generates numbers that satisfy the above criteria.


*

*Preferably, but not necessarily in increasing order.

*Preferably, but not necessarily, all of them (as in, without leaving out any).


At first, it seems that I'm looking at a subset of base 2 palindromes, but I don't know how to generate these numbers.
What would be a simple algorithm to generate these numbers?
 A: Suppose you want to find $p$ for which the sum of some copies of $p$, appropriately shifted, is $2^n-1$.  The shifted copies of $p$ each have the form $2^ap$ for some $a\ge 0$, and their sum is therefore $$2^{a_1}p + 2^{a_2}p + \ldots + 2^{a_k}p$$ for some set of distinct non-negative integers $a_i$. Factoring out the common $p$ in each term, we get $$p\cdot(2^{a_1} + 2^{a_2} + \ldots + 2^{a_k}) = 2^n-1.$$ 
Let us define $q = 2^{a_1} + 2^{a_2} + \ldots + 2^{a_k}$. Then the binary expansion of $q$ is clear: it has a $1$ bit in each $a_k$ position and $0$ bits elsewhere.    The equation $$pq=2^n-1$$ tells us that $p$  must be  a divisor of $2^n-1$, but there is no other restriction on it, and once $p$ is chosen $q$ is completely determined.
So for example, let us find all the possible $p$ for $2^8-1 = 255$.  Divisors of $255$ are $p=1, 3,5,15,17,51,85, 255$; for each such $p$ the corresponding $q$ is $\frac{255}p$, and looking at the binary digits of $q$ tells us the corresponding set of shifts that work for that particular value of $p$:
$$\begin{array}{rrl}
p & q &  \text{shifts of $p$ that add to 255} \\\hline
1  & 11111111_2 & 1\cdot 128+1\cdot 64+1\cdot 32+1\cdot 16+1\cdot 8+1\cdot 4+1\cdot 2+1\cdot 1 \\
3 & 1010101_2 & 3\cdot 64+3\cdot 16+3\cdot 4+3\cdot 1 \\
5 & 110011_2 & 5\cdot 32+5\cdot 16+5\cdot 2+5\cdot 1 \\
15 & 10001_2 & 15\cdot 16+15\cdot 1 \\
17 & 1111_2 & 17\cdot 8+17\cdot 4+17\cdot 2+17\cdot 1 \\
51 & 101_2 & 51\cdot 4+51\cdot 1 \\
85 & 11_2 & 85\cdot 2+85\cdot 1 \\
255 & 1_2 & 255\cdot 1 \\
\end{array}
$$
The same method will also work for a target value that does not have the form $2^n-1$.
A: The general form of your examples falls in the cases of strings formatted with alternating, constant length strings of 1's and 0's where the length of the 0 strings are some multiple of the length of the 1 strings. In Python, the generating statement would look something like this:
binaryString = "{0}{1}" * a + "{0}"
binaryString = binaryString.format("1"*b, "0"*b*k)

Note: this does not consider the cases where you would have to carry digits, only the trivial solutions, i.e. those cases where $n\neq k$.
