int Solution::trailingZeroes(int n) {

int count = 0;

for (int i = 5; n / i >= 1; i *= 5)

count += n / i;

return count;

}

# Fast cpp solution. Can you do, better than this?

**as8297**#1

**rohit-pandit**#2

this is exact solution from gfg not a single word changedâ€¦

if you thought of this on your own then good or maybe u r the one who wrote article on gfg

have this-

int Solution::trailingZeroes(int A) {

```
int sum=0,p=5;
while(A/p)
{
sum+=A/p;
p=p*5;
}
return sum;
```

}

You just need to find out total no. of multiples of 5, 5*5, 5*5*5, and so on.

```
int Solution::trailingZeroes(int a) {
int ans=0;
while(a){
a=a/5;
ans+=a;
}
return ans;
}
```

Yes, check below one.

int Solution::trailingZeroes(int A) {

int five = 5;

int ans = 0;

while(A/five > 0){

ans += A/five;

five *= 5;

}

```
return ans;
```

}