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 189b14b commit 6850d15Copy full SHA for 6850d15
problems/172.factorial-trailing-zeroes.md
@@ -57,7 +57,7 @@ https://leetcode-cn.com/problems/factorial-trailing-zeroes/
57
58
## 代码
59
60
-* 语言支持:JS,Python
+* 语言支持:JS,Python,C++, Java
61
62
Javascript Code:
63
@@ -106,6 +106,41 @@ class Solution:
106
return n // 5 + self.trailingZeroes(n // 5)
107
```
108
109
+C++ Code:
110
+
111
+```c++
112
+class Solution {
113
+public:
114
+ int trailingZeroes(int n) {
115
+ int res = 0;
116
+ while(n >= 5)
117
+ {
118
+ n/=5;
119
+ res += n;
120
+ }
121
+ return res;
122
123
+};
124
+```
125
126
127
+Java Code:
128
129
+```js
130
131
+ public int trailingZeroes(int n) {
132
133
134
135
136
137
138
139
140
+}
141
142
143
144
**复杂度分析**
145
- 时间复杂度:$O(logN)$
146
- 空间复杂度:$O(1)$
0 commit comments