Given an integer n, return the number of trailing zeroes in n!.

给一个数字n,返回它n!数字后面有多少个0。

public class Solution {
public int trailingZeroes(int n) {
int count=0;
while(n/5>=1)
{
count+=n/5;
n/=5;
}
return count;
}
}

trailingZeroes的更多相关文章

  1. Java 计算N阶乘末尾0的个数-LeetCode 172 Factorial Trailing Zeroes

    题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...

  2. [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  3. Leetcode分类刷题答案&心得

    Array 448.找出数组中所有消失的数 要求:整型数组取值为 1 ≤ a[i] ≤ n,n是数组大小,一些元素重复出现,找出[1,n]中没出现的数,实现时时间复杂度为O(n),并不占额外空间 思路 ...

  4. 二刷Cracking the Coding Interview(CC150第五版)

    第18章---高度难题 1,-------另类加法.实现加法. 另类加法 参与人数:327时间限制:3秒空间限制:32768K 算法知识视频讲解 题目描述 请编写一个函数,将两个数字相加.不得使用+或 ...

  5. 【leetcode】Factorial Trailing Zeroes

    题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...

  6. ✡ leetcode 172. Factorial Trailing Zeroes 阶乘中的结尾0个数--------- java

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  7. leetcode 172

    172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: ...

  8. 尽快写完Math!

    (1)Arranging Coins 解题思路一:这个想法是关于二次方程,得到算术和的公式是sum =(x + 1)* x / 2 所以对于这个问题,如果我们知道和,那么我们可以知道x =(-1 + ...

  9. 【leetcode】Factorial Trailing Zeroes(easy)

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

随机推荐

  1. 网站压缩数据 GZIP

    //1.被压缩数据 String str="Hello 你好Hello 你好Hello 你好Hello 你好Hello 你好Hello 你好Hello 你好Hello 你好Hello 你好H ...

  2. [转]XML中必须进行转义的字符

    转自:http://jaenson.iteye.com/blog/945469 编写XML代码经常遗漏的常识: XML实体中不允许出现"&","<" ...

  3. [Oracle] 浅谈Sequence

    Oracle的Sequence是一种数据库对象,它可以生成有序数字,主要用于主键的自动生成.如果没有Sequence,主键的自动生成必须得在代码逻辑里实现,大致过程是:获取当前主键值,新主键值=当前主 ...

  4. [置顶] chinayaosir近10年来所阅读的世界著名IT书籍-图文并茂

    1.人生观(包括做人原则,心理学,投资,销售) 一个人从来到世上,很多东西都是空白, 阅读一些正能量的书籍,把里面的理论用于生活,不断的应用它, 这些观念就会如同软件一样,不断的升级你的大脑, 合理的 ...

  5. mysql 5.7.9(GA) 安装

    mysql 5.7.9(GA) 终于发布了,感受一下. 一.下载 下载页面 http://dev.mysql.com/downloads/mysql/ 选择相应系统的版本下载. 本文OS为centos ...

  6. spring的定时任务或者说自动任务

    http://kevin19900306.iteye.com/blog/1397744   //这个是别人的博客   引入除spring.jar外的Quartz的jar包quartz-all-1.8. ...

  7. Python 一路走来 HTML CSS Javascript

    前端三把利器 HTML          -标签 (成对写不容易忘记闭合)                     自闭和标签           标签里写个 xx=xx, 表示标签的属性       ...

  8. 关于vs2013error C4996: 'strcmpi': The POSIX name for this item is deprecated.的错误解决办法!

    1.出现如下错误(如图1) 2.解决办法(如图2)在头文件处添加#pragma warning(disable: 4996)

  9. CSAPP--存储器及程序的局部性

    作为一名程序员,你需要理解计算机存储系统的层次结构,他对应用程序的性能有着巨大的影响,如果程序所需要的数据存储在cpu的寄存器中,那么指令在执行期间,就可以花费零个周期来进行访问,而在Cache中则需 ...

  10. LIBRARY_PATH和LD_LIBRARY_PATH环境变量的区别

    LIBRARY_PATH和LD_LIBRARY_PATH是Linux下的两个环境变量,二者的含义和作用分别如下: LIBRARY_PATH环境变量用于在程序编译期间查找动态链接库时指定查找共享库的路径 ...