First digits of 2 exponents

36 Views Asked by At

The problem is:

Given a number, find out if this number could be the beginning digits of a 2 exponent & if it can output which power it can be.

As an example given 2 there is answer $8$ which $2 ^ 8 = 256$ which begins with $2$ -> the number given.

Thanks.

1

There are 1 best solutions below

1
On

Such a number always exists,suppose $n$ is the given number, you just need to find an integer $a$ such that the fractional part of $a\log_{10}2$ approximates the fractional part of $\log_{10}(n)$ from above sufficiently well.