326. Power of Three
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
javascript:
/** * @param {number} n * @return {boolean} */ var isPowerOfThree = function(n) { var num=Math.log(n)/Math.log(3); var num1=Math.abs(num-Math.round(num)); if(num1<=0.00000000001) { return true; } else return false; };