Given an integer n, return the number of trailing zeroes in n!.
给一个数字n,返回它n!数字后面有多少个0。
public class Solution {
public int trailingZeroes(int n) {
int count=0;
while(n/5>=1)
{
count+=n/5;
n/=5;
}
return count;
}
}
2024-03-18 22:53:04
Given an integer n, return the number of trailing zeroes in n!.
给一个数字n,返回它n!数字后面有多少个0。
public class Solution {
public int trailingZeroes(int n) {
int count=0;
while(n/5>=1)
{
count+=n/5;
n/=5;
}
return count;
}
}