Code Room
CodingMediumcod-g839
Subject Number theoryLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Implement
factorial_digit_count(n: int) → int
Examples
in[10]out7
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.