#include
using namespace std;
int gcd(int n1,int n2)
{
return n2=0? n1:gcd(n2,n2%n1);
}
int main() {
int n1,n2;
cin>>n1>>n2;
cout<<gcd(n1,n2);
return 0;
}
#include
using namespace std;
int gcd(int n1,int n2)
{
return n2=0? n1:gcd(n2,n2%n1);
}
int main() {
int n1,n2;
cin>>n1>>n2;
cout<<gcd(n1,n2);
return 0;
}
return ((n2 == 0) ? n1 : gcd(n2, n1 % n2));
Try this. And consider saving code at “cb.lk/ide” and sharing link here, rather than the code itself. Much more convenient for all of us.
again its tle coming please check
I have actually submitted the code with the update that I pointed out in your code, it is not giving TLE. Please carefully understand what change have I asked you to make, and/or share the CB IDE link to the code you are trying to submit.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.