Skip to content

Commit 4455ce1

Browse files
add problem 172 add test function
1 parent ce2a1f3 commit 4455ce1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Given an integer n, return the number of trailing zeroes in n!.
3+
* Note: Your solution should be in logarithmic time complexity.
4+
* Created by supercoderhawk on 2017/7/26.
5+
*/
6+
#include <stdio.h>
7+
8+
int trailingZeroes(int n) {
9+
if (n <= 0)
10+
return 0;
11+
12+
int count = 0;
13+
for (long long i = 5; i<=n; i *= 5) {
14+
count += n / i;
15+
}
16+
return count;
17+
}
18+
19+
void testTrailingZeroes() {
20+
printf("%d", trailingZeroes(25));
21+
}

0 commit comments

Comments
 (0)