Will the program work if n1 and n2 are replaced by n1 / 2 and n2 / 2 in line 17 in Listing?
Listing
1 #include <iostream >2 using namespace std;34 int main()5 {6 // Prompt the user to enter two integers7 cout << "Enter first integer: ";8 int n1;9 cin >> n1;10 11 cout << "Enter second integer: ";12 int n2;13 cin >> n2;1415 int gcd = 1;16 int k = 2;17 while (k <<= n1 && k <= n2)18 {19 if (n1 % k == 0 && n2 % k == 0)20 gcd = k;21 k++;22 }23 24 cout << "The greatest common divisor for " << n1 << " and "25 << n2 << " is " << gcd << end⌉;26 27 return 0 ;28 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.