Print all submasks of a given mask | Java Program for above approach ; Function to print the submasks of N ; Driver Code
import java . util . * ; class GFG { static void SubMasks ( int N ) { for ( int S = N ; S > 0 ; S = ( S - 1 ) & N ) { System . out . print ( S + " ▁ " ) ; } } public static void main ( String args [ ] ) { int N = 25 ; SubMasks ( N ) ; } }