You are on page 1of 1

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mcd;

import javax.swing.JOptionPane;

public class Mcd {

public static void main(String[] args) {


int n1,n2;
int mcd = 1;
int minimo;
int i=2;
//constante inicial
n1= Integer.parseInt(JOptionPane.showInputDialog("INGRESE UN NUMERO"));
n2= Integer.parseInt(JOptionPane.showInputDialog("INGRESE UN NUMERO"));
if(n1>n2){
minimo=n2;
}
else {
minimo=n1;
}
do{
if(n1%i==0 && n2%i==0){
mcd=i;
}
i++;

}while(i<=minimo);

JOptionPane.showMessageDialog(null,"El MCD ES "+ mcd);

}
}

You might also like