JacobHsu
5/5/2016 - 1:45 AM

https://leetcode.com/problems/power-of-three/

/**
 * @param {number} n
 * @return {boolean}
 */
var isPowerOfThree = function(n) {
     return n.toString(3).replace(/0/g, '') === '1';
};

/* 
Given an integer, write a function to determine if it is a power of three.
---
var n1 = 9;
console.log(  n1.toString(3) ); // "100"
var n2 = 27;
console.log(  n2.toString(3) ); // "1000"
console.log(  "100".replace(/0/g, '') ); //1
*/