My Super Simple Java Iterative Solution


  • 0
    F
    public int trailingZeroes(int n) {
    	int sum = 0;
    	while (n != 0) {
    		sum += n / 5;
    		n = n / 5;
    	}
    	return sum;
    }

Log in to reply
 

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