题目概述
Given an integer n, return the number of trailing zeroes in n!.
Example 1:
1 |
Input: 3 |
Example 2:
1 |
Input: 5 |
Note: Your solution should be in logarithmic time complexity.
在阶乘中,只有5的倍数能产生0,因此这道题就转化成了n!的因子中有多少个5.
这里需要注意的是,25,125这种数字包含了多个5,需要进行重复计算。
代码实现
1 |
class : |
近期评论