0
$\begingroup$

how do I solve the equation $2^k = xn$ where $n$ and $k$ are known integers and $x$ is unknown integer? Is there some faster way than euclidean algorithm for division?

(In the case it is not solveable in integers, I want to maximize the length of the trail of 0s following the most significant $1$ digit of $xn$)

  • 2
    If $k$, $x$ and $n$ are integers, then $n$ and $x$ are both integral powers of $2$. In this case, just subtract. I don't think that's what you want. Otherwise, you can just take logs (or, equivalently, work with the length of $n$ and $x$ in binary).2017-02-14
  • 1
    By hand or by computer ? Binary or decimal ? How many digits ?2017-02-14
  • 0
    Michael: Yep. Therefore I added the "in case not solveable in integers". Yves Daoust: Preferrably by computer and as fast as possible in hardware. Length.. typically $k\in[16,32]$ I think.2017-02-14
  • 0
    Yes logs is an interesting approach, maybe I can approximate it well in hardware somehow...2017-02-14

0 Answers 0