leetcode Power of Three 题目:https://leetcode.com/problems/power-of-three/
解题思路:不断除以3如果等于1,是3的幂次方,如果不是,不是3的幂次方。
public boolean isPowerOfThree(int n) {
if(n==0){
return false;
}
while(n%3==0){
n=n/3;
}
if(n==1){
return true;
}
return false;
}