// Guide to Java
// Copyright 2014, by J.T. Streib and T. Soma
import java.util.*;
class Gcd {
// method to compute greatest common divisor
private static int gcd(int num1, int num2) {
if(num2 >= 1)
return gcd(num2, num1%num2);
else
return num1;
}
public static void main(String[] args) {
// declaration and initialization of variables
int n, k, result;
Scanner scanner = new Scanner(System.in);
// input two integers
System.out.print("Enter first number: ");
n = scanner.nextInt();
System.out.print("Enter second number: ");
k = scanner.nextInt();
// compute greatest common divisor
result = gcd(n, k);
// output greatest common divisor
System.out.println();
System.out.println("The greatest common divisor of " + n
+ " and " + k + " is " + result + ".");
}
}