Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
Credits:
Special thanks to @ts for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
1 class Solution { 2 public: 3 int trailingZeroes(int n) { 4 int m=0,result=0; 5 int count=log(n)/log(5); 6 for(int i=1;i<=count;i++){ 7 m=pow(5,i); 8 result+=n/m; 9 } 10 return result; 11 12 } 13 };
leetcode Factorial Trailing Zeroes
原文:http://www.cnblogs.com/LUO77/p/5004837.html