Pairs with GCD equal to one in the given range | Java program to print all pairs ; Function to print all pairs ; check if even ; We can print all adjacent pairs for ( int i = l ; i < r ; i += 2 ) { System . out . print ( " { " + i + " , ▁ " + i + 1 + " } , ▁ " ) ; } ; Driver Code
class GFG { static boolean checkPairs ( int l , int r ) { if ( ( l - r ) % 2 == 0 ) return false ; return true ; } public static void main ( String [ ] args ) { int l = 1 , r = 8 ; if ( checkPairs ( l , r ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }