Leetcode: Power of Four Posted on January 10, 2018September 23, 2019 by braindenny Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Similar Problems: CheatSheet: Leetcode For Code Interview Tag: #math Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? Github: code.dennyzhang.com Credits To: leetcode.com Leave me comments, if you have better ways to solve. ## https://code.dennyzhang.com/power-of-four class Solution(object): def isPowerOfFour(self, num): return ((num - 1) & num == 0 and (num-1) % 3 == 0) Post Views: 6