LintCode-(2)尾部的零
来源:互联网 发布:查看数据库表空间 编辑:程序博客网 时间:2024/05/23 15:07
设计一个算法,计算出n阶乘中尾部零的个数
样例
11! = 39916800,因此应该返回 2
public class Solution {/* * @param n: An integer * * @return: An integer, denote the number of trailing zeros in n! */public long trailingZeros(long n) {long i = 0; while(n!=0) {i+=n/5;//n!中有几个5的倍数,结尾就有几个0。25!中有5,15,20,25,有6个5的倍数,结尾就有6个0n=n/5;}return i;}}
阅读全文
0 0
- LintCode 2 尾部的零
- 【LintCode】2、尾部的零
- [Lintcode] #2 尾部的零
- LintCode-(2)尾部的零
- Lintcode 2: 尾部的零
- lintcode 2:尾部的零
- LintCode 尾部的零
- lintcode ---- 尾部的零
- LintCode : 尾部的零
- Lintcode 尾部的零
- LintCode:尾部的零
- Lintcode:尾部的零
- LintCode题解(2)--尾部的零
- (lintcode)第2题尾部的零
- LintCode之2 尾部的零
- LintCode 2 : 尾部的零(java实现)
- Lintcode 尾部零的个数
- LintCode Python 尾部的零
- MATLAB、Python、vs的数组、指针索引问题
- fork 分配pid位图法
- 乐观锁与悲观锁使用场景
- spring源码分析:spring生命周期
- 批量删除
- LintCode-(2)尾部的零
- 决策树
- Pict汇总
- Mybatis_day01
- jsp中request的常见使用方法
- jsp/servlet第一章tomcat
- 自己实现一个JPA中的分页
- SSL/TLS握手过程
- React Hello world