LeetCode:Power of Three
given an integer,write a function to determine if it is a power of three.
class Solution { public: bool isPowerOfThree(int n) { if(n<1) return false; else if(n==1) return true; else return n%3==0&&isPowerOfThree(n/3); } };
given an integer,write a function to determine if it is a power of three.
class Solution { public: bool isPowerOfThree(int n) { if(n<1) return false; else if(n==1) return true; else return n%3==0&&isPowerOfThree(n/3); } };