Why it's showing Wrong Answer?

#include
using namespace std;
int main()
{
int t,i,A,B,x,y;
cin>>t;
for(i=0;i<t;i++)
{
cin>>A>>B;
x=A;
y=B;
while(A!=B)
{
if(A>B)
{
A=(A-B);
}
else
{
B=(B-A);
}
}
cout<<A<<" "<<(x/A)*y<<endl;
}
return 0;
}

1 Like

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Also - what Problem are you trying to solve? :slight_smile:

Please refer to some good articles on how to compute the GCD of two integers using Euler’s Algorithm.
How to compute GCD of two integers
If you have found the GCD then finding LCM is pretty easy, \large LCM = \large \frac{a\cdot b}{GCD(a,b)}