Skip to content

Commit

Permalink
feat(ml):$172.factorial-trailing-zeroes.md (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
ztianming committed Oct 28, 2020
1 parent e635046 commit ddfcecc
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion problems/172.factorial-trailing-zeroes.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ https://leetcode-cn.com/problems/factorial-trailing-zeroes/

## 代码

* 语言支持:JS,Python
* 语言支持:JS,Python,C++, Java

Javascript Code:

Expand Down Expand Up @@ -106,6 +106,41 @@ class Solution:
return n // 5 + self.trailingZeroes(n // 5)
```

C++ Code:

```c++
class Solution {
public:
int trailingZeroes(int n) {
int res = 0;
while(n >= 5)
{
n/=5;
res += n;
}
return res;
}
};
```
Java Code:
```js
class Solution {
public int trailingZeroes(int n) {
int res = 0;
while(n >= 5)
{
n/=5;
res += n;
}
return res;
}
}
```


**复杂度分析**
- 时间复杂度:$O(logN)$
- 空间复杂度:$O(1)$
Expand Down

0 comments on commit ddfcecc

Please sign in to comment.