import java.io.*; class GCD { // Prompts for two numbers and gives their greatest common divisor // (iterative version) public static void main(String[] args) throws IOException { int m,n,rem; BufferedReader in = Text.open(System.in); System.out.print("Enter two numbers: "); m=Text.readInt(in); n=Text.readInt(in); while(n!=0) { rem=m%n; m=n; n=rem; } System.out.println("Greatest common divisor: "+m); } }