ruby daily practice 3

原创文章,转载请注明来源并保留原文链接

谷歌面试题:1024! 末尾有多少个0?

分析:1024的阶乘,就是看1024有多少的2和5,2的个数比5多,那就是看有多少5。

5的倍数,1024/5 = 204
25的倍数,1024/25 = 40
125的倍数,1024/125 = 8
625的倍数:1024/625 = 1

#所以加起来一共 253个0

Leave a Reply

Your email address will not be published. Required fields are marked *