暴力:
class Solution {
public boolean isPowerOfThree(int n) {
if (n <= 0) {
return false;
}
while (n %3 == 0) {
n /= 3;
}
if (n == 1) {
return true;
}
else {
return false;
}
}
}
标签:LC,int,isPowerOfThree,Solution,boolean,public
来源: https://blog.csdn.net/qq_40147944/article/details/122688526