strict female teacher with book pointing at scribbled blackboard
COMPARTE ESTE ARTÍCULO

Por aquí dejo el código de cómo hacer el Mínimo Común Múltiplo en Java. Es un ejercicio típico dde universidades y FP.

/*
 * En esta ocasión voy a hace el Mínimo Común Múltiplo
 */
package MinComunMultiplo;

import java.util.Scanner;

/**
 *
 * @author tgonzalez
 */
public class Minimo {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Scanner sca = new Scanner(System.in);
            int numero;

            System.out.println("Dimame el numero para hacer el MCM");
            numero = sca.nextInt();
            String str = "";

            for (int i = 2; numero != 1 && i < numero; i++) {
                if (numero % i == 0) {
                    str = str + i + "-";
                    numero = numero / i;
                    i = 2;
                }
            }
            str = str + numero;
            //str = str.substring(0, str.length() - 1);
            System.out.println(str);
        } catch (Exception ex) {
            System.out.println("Debes de poner un número entero");
        }

    }

}

Para aprender más de programación ya sea de forma autodidacta, FP o universidad, en nuestra academia contamos con profesionales que te ayudarán en tu aprendizaje.

strict female teacher with book pointing at scribbled blackboard
Photo by Andrea Piacquadio on Pexels.com


NUESTRAS ÚLTIMAS PUBLICACIONES


Contenido restringido

Acceso de usuarios existentes
   
Registro de un nuevo usuario
*Campo necesario

Tags:

Comments are closed

Estado de acceso
ESTADO DE ACCESO
TRADUCTORES
COMPARTENOS
Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert
error: CONTENIDO PROTEGIDO