题目地址:https://leetcode.com/problems/factorial-trailing-zeroes/
public class FactorialTrailingZeroes_172 {
/**
* 5出现的次数比2多
*
* 5 2 -> 10
* 25 4 -> 100
* 125 8 -> 1000
* 625 16 -> 10000
*
* http://www.cnblogs.com/Lyush/archive/2012/08/06/2624549.html
*/
public int trailingZeroes(int n) {
int zeros=0;
int five=5;
while(n>=five){
zeros+=n/five;
if(five>Integer.MAX_VALUE/5)
break;
five*=5;
}
return zeros;
}
}