首页 > 其他 > 详细

342. Power of Four

时间:2019-10-19 10:10:34      阅读:38      评论:0      收藏:0      [点我收藏+]

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

Example 1:

Input: 16
Output: true

Example 2:

Input: 5
Output: false
class Solution {
    public boolean isPowerOfFour(int num) {
         return Math.log10(num) / Math.log10(4) % 1 == 0; 
    }
}

 

342. Power of Four

原文:https://www.cnblogs.com/wentiliangkaihua/p/11702720.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!