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-12-19 20:36:28
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; } }