
LeetCode p172 Factorial Trailing Zeroes 题解
1.题目:
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
题意:
输入n输出n的阶乘的末尾有多少个0.
2.解题思路:
10=2×5
由于2比5多。所以统计因子中所有的5.
3.代码
1 |
|

Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
题意:
输入n输出n的阶乘的末尾有多少个0.
10=2×5
由于2比5多。所以统计因子中所有的5.
1 |
|
近期评论