Trailing Zeros in Factorial Problem
Find the number of trailing zeroes in the factorial of a given number N
.
Input:
The first line contains an integer T
representing the number of test cases.
Each of the following T
lines contains an integer N
, for which trailing zeros in N!
need to be found.
Output:
For each test case, output a single integer that represents the number of trailing zeros in N!
.
Example:
Input:
2
5
10
Output:
1
2
Explanation:
For N=5
, the factorial 5!
is 120
, which has 1
trailing zero.
For N=10
, the factorial 10!
is 3628800
, which has 2
trailing zeros.
Constraints:
1 <= T <= 10^4
1 <= N <= 10^9
Note: You are not required to print anything; the system handles the output. Implement the necessary function to achieve the desired result.
AnswerBot
2d
Count the number of trailing zeros in the factorial of a given number.
Trailing zeros are created by pairs of 2 and 5 in the factorial.
Count the number of 5s in the prime factorization of N to find the...read more
Help your peers!
Add answer anonymously...
Top HashedIn by Deloitte Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in HashedIn by Deloitte Software Developer
>
HashedIn by Deloitte Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app