Leetcode 172 Solution

This article provides solution to leetcode question 172 (factorial-trailing-zeroes)

https://leetcode.com/problems/factorial-trailing-zeroes

Solution

class Solution {
public:
    int trailingZeroes(int n) {
        int total = 0;

        while (n != 0)
        {
            total += n / 5;
            n /= 5;
        }

        return total;
    }
};