Python 程序:计算一个数字的阶乘中尾随零的个数
在本文中,我们将了解如何解决以下问题陈述。
问题陈述 − 我们得到一个整数 n,我们需要计算阶乘中尾随零的个数。
现在让我们在下面的实现中观察解决方案 −
示例
# trailing zero
def find(n):
# Initialize count
count = 0
# update Count
i = 5
while (n / i>= 1):
count += int(n / i)
i *= 5
return int(count)
# Driver program
n = 79
print("Count of trailing 0s "+"in",n,"! is", find(n))输出
Count of trailing 0s in 79 ! is 18

结论
在本文中,我们已经了解如何进行 Python 编程来计算一个数字的阶乘中尾随零的个数
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP