File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ https://leetcode-cn.com/problems/factorial-trailing-zeroes/
5757
5858## 代码
5959
60- * 语言支持:JS,Python
60+ * 语言支持:JS,Python,C++, Java
6161
6262Javascript Code:
6363
@@ -106,6 +106,41 @@ class Solution:
106106 return n // 5 + self .trailingZeroes(n // 5 )
107107```
108108
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+ class Solution {
131+ public int trailingZeroes(int n) {
132+ int res = 0;
133+ while(n >= 5)
134+ {
135+ n/=5;
136+ res += n;
137+ }
138+ return res;
139+ }
140+ }
141+ ```
142+
143+
109144** 复杂度分析**
110145- 时间复杂度:$O(logN)$
111146- 空间复杂度:$O(1)$
You can’t perform that action at this time.
0 commit comments