Untitled
unknown
plain_text
2 years ago
566 B
15
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();Editor is loading...