Code: import java.util.*; class Test{ public static void main(String args[])throws Exception{ Scanner input = new Scanner(System.in); System.out.print(\"Enter the First Number : \"); int n1=input.nextInt(); System.out.print(\"Enter the Second Number : \"); int n2=input.nextInt(); System.out.println(\"GCD : \"+gcd(n1,n2)); } public static int gcd(int n1,int n2){ int r; while(n2 != 0){ r = n1 % n2; n1 = n2; n2 = r; } return n1; } } Output: Enter the First Number : 54 Enter the Second Number : 24 GCD : 6 Solution Code: import java.util.*; class Test{ public static void main(String args[])throws Exception{ Scanner input = new Scanner(System.in); System.out.print(\"Enter the First Number : \"); int n1=input.nextInt(); System.out.print(\"Enter the Second Number : \"); int n2=input.nextInt(); System.out.println(\"GCD : \"+gcd(n1,n2)); } public static int gcd(int n1,int n2){ int r; while(n2 != 0){ r = n1 % n2; n1 = n2; n2 = r; } return n1; } } Output: Enter the First Number : 54 Enter the Second Number : 24 GCD : 6.