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);
        
    }
};
原文地址:https://www.cnblogs.com/xiaoying1245970347/p/5114192.html