Share my C++ solution


  • 0
    V
    class Solution {
    public:
        int trailingZeroes(int n) {
            int ret = 0;
            
            while (n)
            {
                ret += (n / 5);
                n /= 5;
            }
            
            return ret;
        }
    };

Log in to reply
 

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