URL: https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/ Signed-off-by: Matej Focko <me@mfocko.xyz>
15 lines
237 B
Kotlin
15 lines
237 B
Kotlin
class Solution {
|
|
fun checkPowersOfThree(n: Int): Boolean {
|
|
var n = n
|
|
|
|
while (n > 0) {
|
|
if (n % 3 > 1) {
|
|
return false
|
|
}
|
|
|
|
n /= 3
|
|
}
|
|
|
|
return true
|
|
}
|
|
}
|