326. Power of Three

Given an integer, write a function to determine if it is a power of three.

题目含义:给定一个数,判断它是否是3的n次方

思路:使用换底公式

1     public boolean isPowerOfThree(int n) {
2         double res = Math.log10(n) / Math.log10(3);  //有精度问题,不要用以指数2.718为低的log函数  
3         return (res - (int)res == 0) ? true : false;      
4     }
原文地址:https://www.cnblogs.com/wzj4858/p/7701414.html