Will the program work if n1 and n2 are replaced by n1 / 2 and n2 / 2 in line 17 in Listing 1?
LISTING 1 GreatestCommonDivisor.java
1 import java.util.Scanner;
2
3 public class GreatestCommonDivisor {
4 /** Main method */
5 public static void main(String[] args) {
6 // Create a Scanner
7 Scanner input = new Scanner(System.in);
8
9 // Prompt the user to enter two integers
10 System.out.print("Enter first integer: ");
11 int n1 = input.nextInt();
12 System.out.print("Enter second integer: ");
13 int n2 = input.nextInt();
14
15 int gcd = 1; // Initial gcd is 1
16 int k = 2; // Possible gcd
17 while (k <= n1 && k <= n2) {
18 if (n1 % k == 0 && n2 % k == 0)
19 gcd = k; // Update gcd
20 k++;
21 }
22
23 System.out.println("The greatest common divisor for " + n1 +
24 " and " + n2 + " is " + gcd);
25 }
26 }

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.