mycode

问题:为甚在小于200的时候,答案ok,大于等于200的时候,就少一个1???

class Solution(object):
def trailingZeroes(self, n):
"""
:type n: int
:rtype: int
"""
if n<1:
return 0
k = 5
count = 0
while n // k:
count += n // k
k = k*k
#count_2 = 1 if n%10==0 else 0
#if n < 200:
# return count
return count
#30-》 30 .。25.。。20。。15.。。没有数25中的另外一个5!

参考

class Solution(object):
def trailingZeroes(self, n):
"""
:type n: int
:rtype: int
"""
return 0 if n == 0 else n / 5 + self.trailingZeroes(n / 5)

leetcode-mid-math-172. Factorial Trailing Zeroes-NO-????的更多相关文章

  1. 【leetcode❤python】172. Factorial Trailing Zeroes

    #-*- coding: UTF-8 -*-#给定一个整数N,那么N的阶乘N!末尾有多少个0? 比如:N=10,N!=3628800,N!的末尾有2个0.#所有的尾部的0可以看做都是2*5得来的,所以 ...

  2. 【LeetCode】172. Factorial Trailing Zeroes

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

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

    Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...

  4. LeetCode 172. Factorial Trailing Zeroes (阶乘末尾零的数量)

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

  5. Java for LeetCode 172 Factorial Trailing Zeroes

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

  6. 【一天一道LeetCode】#172. Factorial Trailing Zeroes

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  7. 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 ...

  8. ✡ 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 ...

  9. Java [Leetcode 172]Factorial Trailing Zeroes

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

  10. 【LeetCode】172. Factorial Trailing Zeroes 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 递归 循环 日期 题目描述 Given an integer ...

随机推荐

  1. 11.AutoMapper 之值转换器(Value Transformers)

    https://www.jianshu.com/p/b77311546e64 值转换器(Value Transformers) 值转换器应用于单一类型的转换.AutoMapper在分配值之前,会检测该 ...

  2. [转载]Ubuntu如何切换到命令行模式

    来源:https://blog.csdn.net/lyy14011305/article/details/76325067 Ubuntu提供两种进入方式,一个是我们平常最熟悉的图形界面形式,还有一种是 ...

  3. springcloud-概念

    springcloud-概念 一.架构演进过程 单体架构----分布式架构----SOA(eg.dubbo)服务治理架构----微服务 随着互联网的发展,需求的激增致使网站应用规模的扩大,最后转成了技 ...

  4. 剑指offer-2:斐波那契数列

    二.斐波那契数列 题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0). n<=39 1.递归法 1). 分析 斐波那契数列的标准公式为 ...

  5. c#委托(Delegates)--基本概念及使用

    在我这菜鸟理解上,委托就是可以用方法名调用另一方法的便捷方法,可以简化switch等语句的重复.最近做项目的时候恰好需要用到委托,便来复习及学习委托的使用.嗯...本人以前并没有用过,只是稍微知道而已 ...

  6. Java日志打印方法

    一.使用log4j打印日志 1. 下载log4j.jar和commons-logging.jar.     log4j.jar下载地址:http://logging.apache.org/log4j/ ...

  7. python模块之导入包及模块发布

    1.导入包(不常用的方法) 在使用python的包时,有时候想直接导入包名,然后通过包名来调用模块,例如: temp为我们创建的一个包,如果我们想通过下面的方式进行导入模块中的方法,将会出错 impo ...

  8. x64工程属性 选择切换不了

    删除x64工程属性 重新建立新的 配置属性 和导入工程类似  属性冲突 最好重新建立新的工程 解决

  9. Docker(六):Dockerfile命令详解

    Dockerfile 指令详解 1 FROM 指定基础镜像 FROM 指令用于指定其后构建新镜像所使用的基础镜像.FROM 指令必是 Dockerfile 文件中的首条命令,启动构建流程后,Docke ...

  10. 【NOIP2016提高A组模拟9.9】总结

    第一题,题面很不错,正解是分治,不过用ljj水法也可以轻松的所过去. 第二题,本来以为是个有向无环图, 结果搞了半天才发现,事实并不是这样的,于是暂时弃疗, 接着在最后的40分中,某人大喊:哦原来是t ...