My task is to complete the function digitsInFactorial() that takes N as input parameter and returns number of digits in factorial of N.
class Solution{
public:
int digitsInFactorial(int N)
{
long long fact=1;
for(int i=2;i<=N;i++){
fact*=i;
}
int res=0;
while(fact>0){
res++;
fact/=10;
}
return res;
}
}; in this code 1st I find the factorial ,after that I have to find trailing zeros in the factorial . but , it is given incorrect output for the larger number.
New contributor
Nitish Kumar Choudhary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.