import java.util.Scanner; public class GCD { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter first number: "); int a = sc.nextInt(); System.out.print("Enter second number: "); int b = sc.nextInt(); int num1 = a; int num2 = b; while (b != 0) { int temp = b; b = a % b; a = temp; } System.out.println("\nGCD of " + num1 + " and " + num2 + " = " + a); sc.close(); } }