1]. DSA/3]. 450 DSA by ( Love Babbar Bhaiya )/Java/15]. Bit Manipulation/_05)_Power_Of_2_or_Not.java
<gh_stars>0public class PowerOf2orNot {
	
	static boolean isPowerOf2(int n) {
		if(n <= 0) return false;
		// Implement number of set bits
		int setBits = 0;
		while(n != 0) {
			setBits++;
			n&=(n-1);
		}
		if(setBits == 1) return true;
		return false;
	}

	public static void main(String[] args) {
		int n = 4;
        System.out.println(isPowerOf2(n));
	}

}
