int gcd(int a, int b)
{
if(b==0)
return a;
return gcd(b, a%b);
}
int main() {
int t;
cin>>t;
while(t–)
{
int A,B,gcd_value,lcm_value;
cin>>A>>B;
gcd_value=gcd(A,B);
lcm_value=((A*B)/gcd_value);
cout<<gcd_value<<" "<<lcm_value<<endl;
}
return 0;
}
use three backticks on a line either side of code:
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b)
{
if(b==0)
return a;
return gcd(b, a%b);
}
int main() {
int t;
cin>>t;
while(t--)
{
int A,B,gcd_value,lcm_value;
cin>>A>>B;
gcd_value=gcd(A,B);
lcm_value=((A*B)/gcd_value);
cout<<gcd_value<<" "<<lcm_value<<endl;
}
return 0;
}