// Greatest Common Divisor of two integeres according to Euclid's algorithm: // If B=0 then Return A else Return Euclid(B, A mod B) import java.io.*; class Euclid-gcd { public static void main (String[] args) throws IOException { int a, b, t; BufferedReader stdin; stdin = new BufferedReader (new InputStreamReader (System.in)); System.out.print ("Enter first integer: "); a = Integer.parseInt (stdin.readLine()); System.out.print ("Enter second integer: "); b = Integer.parseInt (stdin.readLine()); while (b > 0) { t = a % b; a = b; b = t; } System.out.print ("Their GCD is: " + a); } }