码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode_326 Power Of Three(Binary Manipulation)

时间:2017-04-24 12:15:32      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:rmi   etc   mat   return   ati   code   class   style   strong   

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?

public class Solution {
    public boolean isPowerOfThree(int n) {
        return (Math.log10(n)/Math.log10(3))%1==0;
    }
}

 

leetcode_326 Power Of Three(Binary Manipulation)

标签:rmi   etc   mat   return   ati   code   class   style   strong   

原文地址:http://www.cnblogs.com/ytq1016/p/6755492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!