Find The Number of Trailing Zeroes

379 Views Asked by At

I have 4 Number A,B,C,D I don't know these Number but i know the value of Log Multiplication of these. I have to find the Number of trailing Zeroes in Multiplication of these Numbers. For Ex

Let's  Assume A=10,B=11,C=12,D=13
There Log Multiplication value = log(A)+log(B)+log(C)+log(D) = 4.2345

How to i find the Number of trailing Zeroes in Multiplication of A,B,C,D.
In above case = Answer is 1 (17160)

The value can be very large also so it's not possible to directly calculate it like this 1434221.2232
2

There are 2 best solutions below

4
On

You can directly calculate the product $ABCD$ without knowing the numbers $A,B,C,D$ individually:

$$ \begin{align} ABCD &= 10^{\log(A)}\cdot 10^{\log(B)}\cdot 10^{\log(C)}\cdot 10^{\log(D)} \\ &= 10^{\log(A) + \log(B) + \log(C) + \log(D)} \\ &= 10^{4.2345} \\ & \approx 17160 \\ \end{align} $$

0
On

Let $$\log_{10}(ABCD)=x.a_1a_2a_3\cdots$$

Then, $x+1$ gives the number of digits in $ABCD$ before the decimal point in the decimal system. A negative value gives the number of leading zeroes after the decimal point.

After this, calculate $10^{0.a_1a_2a_3\cdots}$ upto an adequate precision to cover all the digits before the decimal point. It can be checked whether the precision is adequate by checking that adding a digit after the decimal point has no effect on any digits before the decimal point in the result.

Note that however large the number may be, it is always true that $|10^{0.a_1a_2a_3\cdots}|<10$.