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; } }

 

posted @ 2016-01-18 15:50  *桔子*  阅读(142)  评论(0编辑  收藏  举报