1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-10 00:09:06 +01:00

problems(kt): add „326. Power of Three“

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-08-24 12:34:37 +02:00
parent 13c5b4b30a
commit 3bcb7469d9
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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
}
}