# GCD and LCM

You will be given two integers A, B. If A × B (product of A and B) is equal to LCM(A, B) then you ha…

If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

``````#include<iostream>
using namespace std;

int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}

int main()
{
int n;
cin >> n;
int a, b;
for(int i=1; i<=n; i++)
{
cin >> a >> b;
if(gcd(a, b) == 1)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return 0;
}
``````

What’s the problem with my code?

You are using `int a, b`. You need a larger type here. Because the numbers in the input can be as large as 1018.

#include
using namespace std;
int main()
{
int num,i;
long long a,b,m,n,rem,div;
cin>>num;
for(i=0;i<num;i++)
{
cin>>a>>b;
m=a;
n=b;
while(n!=0)
{
rem=m%n;
m=n;
n=rem;
}
div=(ab)/m;
if(a
b==div)
{
cout<<“yes”<<endl;
}
else
cout<<“no”<<endl;
}
}
what is the problem in this code??