Leetcode: Factorial Trailing Zeroes
2015-08-27 01:59
357 查看
Question
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.
Show Tags
Show Similar Problems
Solution
Analysis
Count how many factor 5 in n!Code
[code]class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ res = 0 while n!=0: res = res + n/5 n /= 5 return res
相关文章推荐
- ideaiu的使用
- CCComponentContainer,CCComponent解析
- 安装APK:Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
- 异常:org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) B. Minimization 贪心 dp
- LeetCode题解:Factorial Trailing Zeroes
- HDU2473 - Junk-Mail Filter 利用虚拟数组实现删除并查集的节点
- 【图论】【最小生成树】[IOI2003]maintain
- [捉虫记录]关于Cascade Training Error的bug
- failure during conversion to COFF: file invalid or corrupt
- 【HDOJ 1021】 Fibonacci Again (矩阵快速幂(裸))
- HDOJ 2674 N!Again(找规律)
- 人工智能进入股市操盘获利巨大激荡股市
- See You Again
- B. Order Book------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- A. Arrays------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) A. Lengthening Sticks 分类
- 1.2句柄及 WinMain函数
- ACdream 1420 High Speed Trains(容斥原理)
- MainActivity,BadgeView