Find two distinct numbers such that their LCM lies in given range | C ++ program for the above approach ; Function to find two distinct numbers X and Y s . t . their LCM lies between L and R and X , Y are minimum possible ; Check if 2 * L lies in range L , R ; Print the answer ; Driver Code ; Given value of ranges ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; void answer ( int L , int R ) { if ( 2 * L <= R ) cout << L << " , ▁ " << 2 * L << " STRNEWLINE " ; else cout << -1 ; } int main ( ) { int L = 3 , R = 8 ; answer ( L , R ) ; return 0 ; }