> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0172_factorial_trailing_zeroes/slt.md).

# 思路1 数学方法

首先题目的意思是末尾有几个0 比如`6! = 【1* 2* 3* 4* 5* 6】` 其中只有2*5末尾才有0，所以就可以抛去其他数据 专门看2 5 以及其倍数 毕竟 4* 25末尾也是0 比如`10！ = 【2*4*5*6*8*10】` 其中 4能拆成`2*2` 10能拆成2*5 所以\`10！ = 【2*（2*2）*&#x35;*（2*3）*（2*2*2）*（2\*5）】\` 一个2和一个5配对（即10） 就产生一个0 所以10！末尾2个0

转头一想 2肯定比5多 所以只数5的个数就行了

假若N=31 31!里能凑10的5为`[5, 2*5, 3*5, 4*5, 25, 6*5]` 其中 25还能拆为`5**2` 所以 里面的5的个数为 `int(31/(5**1)) + int(31/(5**2))` 所以 只要先找个一个`5**x < n`的x的最大数 然后按上面循环加起来

最后即是求乘法因子里有多少个5的倍数（2比5多，2 \* 5 即凑成一个10）
