-
-
Save sanrodari/2589573 to your computer and use it in GitHub Desktop.
Mire
This file contains hidden or 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 com.example; | |
| 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