Skip to content

Commit 0c70b93

Browse files
authored
feat: add ts solution to lc problem: No.1780 (doocs#1487)
1 parent 7565369 commit 0c70b93

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

solution/1700-1799/1780.Check if Number is a Sum of Powers of Three/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ func checkPowersOfThree(n int) bool {
115115
}
116116
```
117117

118+
### **TypeScript**
119+
120+
```ts
121+
function checkPowersOfThree(n: number): boolean {
122+
while (n) {
123+
if (n % 3 > 1) return false;
124+
n = Math.floor(n / 3);
125+
}
126+
return true;
127+
}
128+
```
129+
118130
### **...**
119131

120132
```

solution/1700-1799/1780.Check if Number is a Sum of Powers of Three/README_EN.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ func checkPowersOfThree(n int) bool {
100100
}
101101
```
102102

103+
### **TypeScript**
104+
105+
```ts
106+
function checkPowersOfThree(n: number): boolean {
107+
while (n) {
108+
if (n % 3 > 1) return false;
109+
n = Math.floor(n / 3);
110+
}
111+
return true;
112+
}
113+
```
114+
103115
### **...**
104116

105117
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function checkPowersOfThree(n: number): boolean {
2+
while (n) {
3+
if (n % 3 > 1) return false;
4+
n = Math.floor(n / 3);
5+
}
6+
return true;
7+
}

0 commit comments

Comments
 (0)