Finding the First Digit of a Number – Methods

elementary-number-theorynumber theory

I have seen this question but i could not find any answers.Let

A= a*b*c*d....   very huge multiplication

So what we can do take log(base 10) of number

log(A) = log(a)+log(b)+log(c).....
log(A) = S (summation of logs)

From here onward how can i find the first digit.
I came to know that

Fist digit = Number after decimals in S which is close to log of (1..9) 

Can you explain how to do that ?

Best Answer

Given the number $N$, compute $log_{10}(N)$, take the fractional part (lets denote that with $f$) and calculate $10^f$. Truncate $10^f$ to get the first digit of $N$.

Example :

$N=2^{64}$

$log_{10}(N)=19.2659$

$10^{0.2659}=1.84...$

First digit : $1$

In the case of $9\cdot 10^5$ for example, this method fails because $10^f=8.9999\cdots\ $ (The number of $9's$ depends on the accuracy of $10^f$), but the correct answer is $9$. But the method will work well if not too many zeros follow the first digit.

Why does the method work ?

Let $s$ be the number with $10^s=N$. If $f$ is the fractional part of $s$ and $t$ the truncation of $s$, we have $N=10^s=10^{t+f}=10^t\cdot 10^f$. So we multiply $10^f$ with a number of the form $10^k$, so the first digit of $10^f$ is also the first digit of $N$.