Easy to understand java code


  • 0
    A
    public class Solution { // in Dennis Moul class :)
        public int trailingZeroes(int n) {
            long num = 5;
            int five = 5;
            int count = 0;
            
            while (num <= n) {
                count +=(int) (n / num);
                num = num * five;
            }
            return count;
        }
    }
    

Log in to reply
 

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