Skip to content

Instantly share code, notes, and snippets.

@godie007
Created May 3, 2012 20:17
Show Gist options
  • Save godie007/2588978 to your computer and use it in GitHub Desktop.
Save godie007/2588978 to your computer and use it in GitHub Desktop.
Mire
package Empresa;
import javax.swing.JOptionPane;
public class MinimoComunMultiplo {
public static void main(String[] args) {
int a,b,t,t1,x;
a=Integer.parseInt(JOptionPane.showInputDialog("A"));
b=Integer.parseInt(JOptionPane.showInputDialog("B"));
t=1; //constante inicializada para evitar la multiplicidad x cero
x=2; //constante inicial
while (x<=a && x<=b)
{
while (a%x==0 && b%x==0)
{
a=a/x;
b=b/x;
t=t*x;
}
x++;
}
t1=t;
t=t*a*b;
System.out.println("El mcm es :" +t);
System.out.println("El mcd es :" +t1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment