LeetCode编程练习 - Factorial Trailing Zeroes学习心得
题目:
Given an integern,
return the number of trailing zeroes inn!.
Note:Your solution should be in logarithmic time complexity.
给定一个整数n,返回n!中后面的0的个数。解决方案应该是对数时间复杂度。
思路:
后缀为0其实就是除了包含0本身2*5得到的,想要判断后面有几个0,只要判断有几个2,几个5,综合一下,由于2的倍数较多,以选择5的个数来判断,用除5取商就可以判断5的个数。