C# solution: count for 5 because the number of 2 much more than 5.


  • 0
    B
    public class Solution
    {
    	public int TrailingZeroes(int n)
    	{
    		if (n <= 0) return 0;
    
    		int count = 0;
    		while (n > 0)
    		{
    			count += n / 5;
    			n /= 5;
    		}
    
    		return count;
    	}
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.