Total Accepted: 76257
Total Submissions: 194942
Difficulty: Easy
Contributors: Admin
Given an integer, write a function to determine if it is a power of three.
class Solution {
public:
bool isPowerOfThree(int n) {
if(n==0)return false;
while(n!=0){
if(n%3!=0&&n!=1)return false;
n=n/3;
}
return true;
}
};