Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution {

public:

int trailingZeroes(int n) { int sum=0; for (int i = n/5; i>0; i/=5) sum += i; return sum; }

};

why my solution gives wrong answer; Solution: int trailingzeros(int n) { int cnt=0; for(int i=5;(n/i)>=1;i*=5) cnt+=(n/i); return cnt; }

This solution gives output: Input: 1808548329 Output: 452137080 Expected: 452137076

why so.. please explain... thanks.. :)

Maybe the problem is : (n/i)>=1 I thought it should be: (n/i) >= 5

because the int overflow,in the last time i=i*5,the result should be larger than the up-limit int type and then becomes a small number,so your amount of the zeros will be more than the ans

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