# Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

C直接来两轮，提交

```int trailingZeroes(int n) {
int i, tmp;
int j = 0;
for (i = 1; i <= n; i++){
tmp = i;
while (tmp % 5 == 0){
++j;
tmp = tmp / 5;
}
}
return j;
}```

```Submission Result: Time Limit Exceeded

Last executed input:	1808548329```

```int trailingZeroes(int n) {
int i, tmp;
int j = 0;
for (i = 5; i <= n; i += 5){
tmp = i;
while (tmp % 5 == 0){
++j;
tmp = tmp / 5;
}
}
return j;
}```

```Submission Result: Time Limit Exceeded

Last executed input:	1808548329```

```int trailingZeroes(int n) {
int i, tmp;
int j = 0;
for (i = 5; i <= n; i += 5){
tmp = i / 5;
++j;
while (tmp % 5 == 0){
++j;
tmp = tmp / 5;
}
}
return j;
}```

```Submission Result: Time Limit Exceeded

Last executed input:	1808548329```

```int trailingZeroes(int n) {
int j = 0;
while (n){
j += n / 5;
n = n / 5;
}
return j;
}```

```502 / 502 test cases passed.
Status: Accepted
Runtime: 3 ms```