标签:
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
思路:
不会做。先百度阶乘最后有几个零,知道了方法剩下的就很简单了。
很佩服他们,可以想出这个方法。
题解:
class Solution { public: int trailingZeroes(int n) { int res = 0; while(n) { n /= 5; res += n; } return res; } };
[leetcode] Factorial Trailing Zeroes
标签:
原文地址:http://www.cnblogs.com/jiasaidongqi/p/4226406.html