Sharing my 4ms C++ solution


  • 1
    T
    class Solution {
    public:
        int trailingZeroes(int n) {
            int result=0;
            long long int i;
            for(i=5; i<=n; i=i*5)
                result += n/i;
                
            return result;
        }
    };

Log in to reply
 

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