- leetcode:172. Factorial Trailing
- [String]172. Factorial Trailing
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
- 172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.
**Note: **Your solution should be in logarithmic time complexity.
Solution:
class Solution {
public:
int trailingZeroes(int n) {
int r = 0;
while(n >= 5){
n = n / 5;
r+=n;
}
return r;
}
};
网友评论