Generate a pair of integers from a range [ L , R ] whose LCM also lies within the range | C ++ implementation of the above approach ; Checking if any pair is possible or not in range ( l , r ) ; If not possible print ( - 1 ) ; Print LCM pair ; Driver code ; Function call
#include <iostream> NEW_LINE using namespace std ; void lcmpair ( int l , int r ) { int x , y ; x = l ; y = 2 * l ; if ( y > r ) { cout << " - 1 STRNEWLINE " ; } else { cout << " X ▁ = ▁ " << x << " ▁ Y ▁ = ▁ " << y << " STRNEWLINE " ; } } int main ( ) { int l = 13 , r = 69 ; lcmpair ( l , r ) ; return 0 ; }