Given an integer of the form: $2^j*3^k$ - is there a way to quickly find j and k?

65 Views Asked by At

Suppose you have a number that you know is of the form: $2^j*3^k$ (j,k are positive integers). Is there a way to quickly (ie constant,linear time) find what j and k are?

Basically is there a faster way to determine what j and k are without repeatedly dividing by 2 (or 3) until you hit a get a real number?

1

There are 1 best solutions below

0
On

Quickly, as in polynomial in $j$ and $k$? Yes. In constant time? That is an easy No. Even checking whether a number is dividable by 3 involves adding up all the digits and seeing if they are dividable by 3. This cannot be done in constant time.

In fact, for every integer $\ell$ there are an infinite number of combinations $(j,k)$ s.t. $2^j3^k$ is the same mod $10^{\ell}$ so looking at the first $\ell$ digits will not help.