Pairs with GCD equal to one in the given range | C ++ 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 ) { cout << " { " << i << " , ▁ " << i + 1 << " } , ▁ " ; } ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool checkPairs ( int l , int r ) { if ( ( l - r ) % 2 == 0 ) return false ; return true ; } int main ( ) { int l = 1 , r = 8 ; if ( checkPairs ( l , r ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }