Created
May 3, 2012 20:17
-
-
Save godie007/2588978 to your computer and use it in GitHub Desktop.
Mire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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