Solving Diophantine Equation $xB=(2^N)-1$ If given a value for $x$, does anyone have a way to solve the diophantine equation below?
$xB=(2^N)-1$
where $x,B,N\in\mathbb Z$
Where presumably a smaller $N$ is better, but any way to find a value of $N$ (and $B$) is a good solution.
All i can think of is brute force unfortunately... trying ever increasing values of $N$ to see if $(2^N)-1$ is a perfect multiple of $x$
 A: I presume you mean the positive integers, not $\mathbb Z$, else you could take $B=N=0$.  You want the least positive $N$ such that $2^N \equiv 1 \mod x$.  If $x$ is even, this is impossible, else it is the order of $2$ in the multiplicative group of units of $\mathbb Z/x\mathbb Z$.  Start with Euler's theorem.  If you can factor $\phi(x)$ it's easy.
A: So, given $x$, we have to find minimum $N$ and $B$, so that
$$
x\,B = 2^{\,N}  - 1\quad  \Rightarrow \quad x,B\;{\rm odd}
$$
I can provide just some preliminary considerations.
Let represent all three parameters in binary base.
Take $x$ to be:
$$
x = {\rm odd} = 1\;b\; \cdots \;b\,\;1_2 \;(m\;{\rm bits}) < 2^{\,m} 
$$
Then we must have:
$$
x\,B\, = 2^{\,N}  - 1 = 1\;\,1\,\; \cdots \;\,1_2 
$$
Since binary multiplication translates into the sum of shifted $x$ strings,
then the identity above means :
start with $x*1$ , then add a $x$-string shifted so that its LSB=$1$ fits with the first $0$, compute the sum, continue with next $0$.
So the question becomes for which values of $x$ this iteration terminates, and we know there are some.
If $N$ satisfies the identity, then the next following multiple of it shall be
$$
q\;:\quad 2^{\,M}  - 1 = q\left( {2^{\,N}  - 1} \right)
$$
Since we have
$$
{{2^{\,M}  - 1} \over {2 - 1}} = \sum\limits_{0\, \le \,k\, \le \,M - 1} {2^{\,k} }  = \sum\limits_{0\, \le \,k\, \le \,N - 1} {2^{\,k} }  + 2^{\,N} \sum\limits_{0\, \le \,k\, \le \,M - N - 1} {2^{\,k} } 
$$
Thus the minimum $q$ will be
$$
2^{\,2N}  - 1 = \left( {2^{\,N}  + 1} \right)\left( {2^{\,N}  - 1} \right)\quad  \Rightarrow \quad \min \;q = \left( {2^{\,N}  + 1} \right)
$$
and thus either there is no solution or there are infinite.
(added)
We deduce that a solution exists for all the $x$ that have a periodic binary representation, where the number of consecutive $1$s is congruent with the number of consecutive $0$s.
Example:
$x = 1\,1\;0\;0\;0\;0\;1\;1_{\,2}  = 195$
$B = 1\,0\;1\;0\;1_{\,2}  = 21$
$x\,B = 4095 = 2^{\,12}  - 1$
