Factorial digit count

Write codeMedium20 min

Your task

Return the number of decimal digits in n! (n factorial) for n up to about 10^5, without materializing the huge factorial. The number of digits of a positive integer x is floor(log10(x)) + 1, and log10(n!) = sum of log10(k) for k from 1 to n. Accumulate that sum in floating point and return floor(sum) + 1. By convention, 0! = 1! = 1 has 1 digit. Return 0 for n < 0.

Examples

factorial_digit_count(n: int) -> int
Example 1
Inputfactorial_digit_count(10)
Output7