Answers for "how to find number of digits in a factorial"

0

how to find number of digits in a factorial

We know,
log(a*b) = log(a) + log(b)

Therefore
log( n! ) = log(1*2*3....... * n) 
          = log(1) + log(2) + ........ +log(n)

Now, observe that the floor value of log base 
10 increased by 1, of any number, gives the
number of digits present in that number.

Hence, output would be : floor(log(n!)) + 1.
Posted by: Guest on May-15-2021

Code answers related to "how to find number of digits in a factorial"

Browse Popular Code Answers by Language