Skip to content

Commit 78726f2

Browse files
authored
Create 1780. Check if Number is a Sum of Powers of Three
1 parent 1e6d662 commit 78726f2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
bool checkPowersOfThree(int n) {
4+
while(n > 0){
5+
int remainder = n % 3;
6+
if(remainder == 2){
7+
return false;
8+
}
9+
n = n / 3;
10+
}
11+
return true;
12+
}
13+
};

0 commit comments

Comments
 (0)