找到int范围内最大的3的幂的数,然后将其对n取余即可class Solution { public boolean isPowerOfThree(int n) { return (n > 0 && Math.pow(3,21) % n == 0); } } Last Modified: October 10, 2018 Archives Tip