Answer to Question #5289 in C++ for aimelawan
3. Make a program that determines whether two input numbers are coprime or not. Two numbers are coprime if the only positive number that perfectly divides them is 1. In other words, two numbers can be coprime only if their gcd is 1.
int A, B, minAB;
bool prime = true;
cout<<"Enter number A: ";
cout<<"Enter number B: ";
if (A<=B) minAB = A;
else minAB = B;
& if ((A%i==0)&&(B%i==0)) prime = false;
if (prime == true) cout<<"A and B are coprime.";
else cout<<"A and B are not coprime.\r\n";
No comments. Be first!