您的位置: 首页 > IT文章 > LintCode Python 简单级题目 2.尾部的零 LintCode Python 简单级题目 2.尾部的零 分类: IT文章 • 2024-09-05 11:53:19 原题描述: 设计一个算法,计算出n阶乘中尾部零的个数 样例 11! = 39916800,因此应该返回 2 挑战 O(logN)的时间复杂度 标签 数学 题目分析: 设计一个算法,计算出n阶乘中尾部零的个数 源码: class Solution: # @param n a integer # @return as a integer def trailingZeros(self, n): if n == 0 : return 1 x = 1 while n>5: x += n/5 n = n/5 return x-1