8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 127aeba commit 514b71dCopy full SHA for 514b71d
FactorialTrailingZeroes.cpp
@@ -0,0 +1,25 @@
1
+/*
2
+ Author: King, wangjingui@outlook.com
3
+ Date: Dec 13, 2014
4
+ Problem: Factorial Trailing Zeroes
5
+ Difficulty: Easy
6
+ Source: https://oj.leetcode.com/problems/factorial-trailing-zeroes/
7
+ Notes:
8
+ Given an integer n, return the number of trailing zeroes in n!.
9
+
10
+ Note: Your solution should be in logarithmic time complexity.
11
12
+ Solution: ...
13
+ */
14
15
+class Solution {
16
+public:
17
+ int trailingZeroes(int n) {
18
+ int res = 0;
19
+ while (n) {
20
+ res += n / 5;
21
+ n /= 5;
22
+ }
23
+ return res;
24
25
+};
0 commit comments