/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/GCDDoWhile.java |
package mp3_calebfontenot;
@author
public class GCDDoWhile {
public static void main(String[] args) {
java.util.Scanner input = new java.util.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();
int d = (n1 < n2) ? n1 : n2;
do {
if ((n1 % d == 0) && (n2 % d == 0)) {
break;
}
d--;
} while (d >= 1);
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
}
}