Factorial Trailing Zeroes
2016-01-18 19:20
375 查看
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
答案解释可以看 陈皓在leetcode Discuss上的答案:https://leetcode.com/discuss/19847/simple-c-c-solution-with-detailed-explaination
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
答案解释可以看 陈皓在leetcode Discuss上的答案:https://leetcode.com/discuss/19847/simple-c-c-solution-with-detailed-explaination
int trailingZeroes(int n) { int result = 0; for (long long i = 5; n / i>0; i *= 5) { result += (n / i); } return result; }
相关文章推荐
- Gitlab RPC failed; result=22, HTTP code = 413 解决方法
- ftk学习记(waitbox篇)
- DataOutputStream、DataInputStream
- Closed kinematic chain - how to control it
- Aix6.1操作系统安装教程
- 7.4 决策树
- 3.4wait的条件发生变化导致逻辑错误
- raid详细介绍
- (assign,retain,copy):
- 美国末日AI之状态机(The Last Of Us AI)
- GPG key generation: Not enough random bytes available.
- Project Euler 102:Triangle containment 包含原点的三角形
- Syntax error, parameterized types are only available if source level is 1.5 or greater
- RAID5单块和多块硬盘故障如何恢复
- 3.3wait(long)
- GTP协议的分析 http://blog.csdn.net/stephen_yin/article/details/6951258
- <蜡烛图精解Candlestick Charting Explained>-- 笔记1
- GTP(GPRS Tunnelling Protocol)协议http://blog.csdn.net/stephen_yin/article/details/6951237
- 3.1等待/通知机制(wait/notify)
- [leetcode] 219. Contains Duplicate II 解题报告