Trailing zeroes-video example

Can we have any other method for this question?

My method would be calculating factorial and extracting zeroes from the end by increasing the counter and printing it finally.

Please explain to me.

see
since 100! could be asked in the question and acc to permissible time complexity for code with factorial time complexity


n can be at max 12
so u can never calculate the trailing zeros beyond N = 12

hence u will have to check out this optimised approach

okay maam is there any other method of solving such problems.

did u check out the video its solution is quite simple

int trailingZeroes(int A) {
    long long base = 5; 
    int ans = 0;
        while(true){
            int curr = A/base;
            ans+= curr;
            if(curr<= 0 )return ans;
            base*=5;
        }
        return 0;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.