Given an integer, write a function to determine if it is a power of two.
class Solution { public boolean isPowerOfTwo(int n) { if(n == 0) return false; while(n%2 == 0){ n = n/2; } return n==1; } } This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:
Original author:Jake Tao,source:"231. Power of Two"