Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
566 B
8
Indexable
Scanner input = new Scanner(System.in);
        System.out.print("Ingrese un numero mayor de 0: ");
        int numero = input.nextInt();
        while (numero <= 0) {
            System.out.print("Ingrese un numero mayor de 0: ");
            numero = input.nextInt();
        }
        int fact = 1;
        String operacion = "1";
        for (int i = 2; i <= numero; ++i) {
            fact *= i;
            operacion = operacion + " * " + i;
        }
        System.out.println(numero + "! = " + operacion + " = " + fact);
        input.close();