diff --git a/problems/power-of-three.kt b/problems/power-of-three.kt new file mode 100644 index 0000000..1828022 --- /dev/null +++ b/problems/power-of-three.kt @@ -0,0 +1,13 @@ +class Solution { + fun isPowerOfThree(n: Int): Boolean { + if (n < 1) { + return false + } + + var x = n + while (x % 3 == 0) { + x /= 3 + } + return x == 1 + } +}