Skip to content

Commit b1d5a12

Browse files
1780_Check_if_number_is_sum_of_Powers_of_Three.java
1 parent 68275be commit b1d5a12

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Problem Number: 1780
2+
3+
// Check if number is a Sum of Powers of Three.
4+
5+
class Solution {
6+
public boolean checkPowersOfThree(int n) {
7+
while (n > 1) {
8+
int r = n % 3;
9+
if (r == 2)
10+
return false;
11+
n /= 3;
12+
}
13+
14+
return true;
15+
}
16+
}

0 commit comments

Comments
 (0)