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. git常用命令之log

       查看提交日志记录 基础命令:  git log commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon < ...

  2. call apply bind sleep

    1.自己实现一个call 1)利用对象的方式的形式改变this指针 funcion add; add.call(temObj) 只需要 在temObj对象临时添加一个方法即可 Function.pro ...

  3. 【应用容器引擎】Docker笔记

    一.Docker是什么? Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的linux机器上,也可以实现虚拟化.它是一个轻量级容器技 ...

  4. GetShortPathName函数

    Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathName" (ByVal ...

  5. (转) Oracle SQL优化必要的全表扫描思路分析

    大多数情况下,我们需要避免SQL在查询时进行全表扫描(FTS),但是对于必须需要进行全表扫描的情况,也可以进行一些优化处理. 即使全表扫描是检索所需数据的唯一可行方法,仍然有多种方法来提升查询性能.优 ...

  6. JVM metaspace元空间

    元空间的本质和永久代类似,都是对JVM规范中方法区的实现. 元空间不在虚拟机中,而是使用本地内存. 用于元空间的JVM参数:   -XX:MetaspaceSize=N 初始化Metaspace大小, ...

  7. ZROI 19.08.03 分治与离线

    经典问题,给一张图,支持加边/删边/询问两点连通性. 离线统计边权(删除时间),lct维护最大生成树即可. 也可以按时间分治,维护一个可回退并查集即可. 主定理 很好用,但是记不住. 有一种简明的替代 ...

  8. java面向对象3-继承(继承、抽象类、抽象接口)

    4.继承 面向对象概念-类与对象的关系 封装:指隐藏对象的属性和实现细节,仅对外提供公共访问方式,private-构造方法/构造器-this关键字-static关键字(javadoc制作工具类) -代 ...

  9. Codeforces Round #568 (Div. 2) A.Ropewalkers

    链接: https://codeforces.com/contest/1185/problem/A 题意: Polycarp decided to relax on his weekend and v ...

  10. 【shell】文本匹配问题

    原文本通过TITLE分段 TITLE1 xxx yyy TITLE2 xxx yyy hello zzz hello TITLE3 xxx hello 类似于这样的,hello可能有多个,需要打印出含 ...