326.3的幂
class Solution {
public:
bool ifPowerofN(int n,int num){
while (n%num==0){
n/=num;
}
return n==1;
}
bool isPowerOfThree(int n) {
if (n==0) return false;
return ifPowerofN(n,3);
}
};
修改3的数值 可以用来测试不同的幂