/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/GCD.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package mp3_calebfontenot;

/**
 *
 * @author caleb
 */
public class GCD {
    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;
        for (; d >= 1; d--)
            if ((n1 % d == 0) && (n2 % d == 0))
                break;
        System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
    }
}