Non | Java program for the above approach ; Function to print all pairs whose sum of Bitwise OR and AND is N ; Iterate from i = 0 to N ; Print pairs ( i , N - i ) ; Driver code
import java . util . * ; import java . lang . * ; class GFG { static void findPairs ( int N ) { for ( int i = 0 ; i <= N ; i ++ ) { System . out . print ( " ( " + i + " , ▁ " + ( N - i ) + " ) , ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 5 ; findPairs ( N ) ; } }