你们在后院晒衣服都用得是什么?# Living
m*6
1 楼
题目:Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.
int findTrailingZeros(int n)
{
// Initialize result
int count = 0;
// Keep dividing n by powers of 5 and update count
for (int i=5; n/i>=1; i *= 5)
count += n/i;
return count;
}
为什么这个代码不能通过下面的测试:
Input: 1808548329
Output: 452137080
Expected: 452137076
Given an integer n, return the number of trailing zeroes in n!.
int findTrailingZeros(int n)
{
// Initialize result
int count = 0;
// Keep dividing n by powers of 5 and update count
for (int i=5; n/i>=1; i *= 5)
count += n/i;
return count;
}
为什么这个代码不能通过下面的测试:
Input: 1808548329
Output: 452137080
Expected: 452137076