本文最后更新于:2023年12月5日 下午

学而时习,本文记录数学相关算法练习笔记。

172. 阶乘后的零

给定一个整数 n ,返回 n! 结果中尾随零的数量。

提示 n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1

1
2
3
4
5
6
7
8
class Solution:
def trailingZeroes(self, n: int) -> int:
ans = 0
while n:
n //= 5
ans += n
return ans



文章链接:
https://www.zywvvd.com/notes/study/algorithm/math/about-math/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

算法学习笔记 —— 数学
https://www.zywvvd.com/notes/study/algorithm/math/about-math/
作者
Yiwei Zhang
发布于
2020年5月21日
许可协议