Skip to content

Commit 59f80e8

Browse files
authored
feat: add typescript solution to lc problem: No.0172.Factorial Trailing Zeroes (doocs#490)
1 parent cca1701 commit 59f80e8

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

solution/0100-0199/0172.Factorial Trailing Zeroes/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
<!-- 这里可写通用的实现逻辑 -->
2929

30+
统计5的个数
31+
3032
<!-- tabs:start -->
3133

3234
### **Python3**
@@ -45,6 +47,19 @@
4547

4648
```
4749

50+
### **TypeScript**
51+
52+
```ts
53+
function trailingZeroes(n: number): number {
54+
let count = 0;
55+
while (n > 0) {
56+
n = Math.floor(n / 5);
57+
count += n;
58+
}
59+
return count;
60+
};
61+
```
62+
4863
### **...**
4964

5065
```

solution/0100-0199/0172.Factorial Trailing Zeroes/README_EN.md

+13
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@
5656

5757
```
5858

59+
### **TypeScript**
60+
61+
```ts
62+
function trailingZeroes(n: number): number {
63+
let count = 0;
64+
while (n > 0) {
65+
n = Math.floor(n / 5);
66+
count += n;
67+
}
68+
return count;
69+
};
70+
```
71+
5972
### **...**
6073

6174
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function trailingZeroes(n: number): number {
2+
let count = 0;
3+
while (n > 0) {
4+
n = Math.floor(n / 5);
5+
count += n;
6+
}
7+
return count;
8+
};

0 commit comments

Comments
 (0)