Power of Three


不能使用循环和迭代,所以用log喽

public
class Solution { public bool IsPowerOfThree(int n) { if(n==0) return false; if(n<0) return false; return ( ( (Math.Log(Math.Abs(n),3)) - (int) (Math.Log(Math.Abs(n),3)+Math.Pow(10,-10))) )<=Math.Pow(10,-10)?true:false; } }
原文地址:https://www.cnblogs.com/julie-yang/p/5139502.html