Print bitwise AND set of a number N | Java program to print all bitwise subsets of N ( Efficient approach ) ; function to find bitwise subsets Efficient approach ; Driver Code
class GFG { static void printSubsets ( int n ) { for ( int i = n ; i > 0 ; i = ( i - 1 ) & n ) System . out . print ( i + " ▁ " ) ; System . out . print ( " ▁ 0 ▁ " ) ; } public static void main ( String [ ] args ) { int n = 9 ; printSubsets ( n ) ; } }