Está en la página 1de 1

/*

FACTORIAL DE UN NÚMERO
5! 1*2*3*4*5 = 120
*/
package miprimerprograma;

import javax.swing.JOptionPane;
public class factorial {

public static void main(String [] args){


int numero;
int ac=1;
int i;
numero =Integer.parseInt(JOptionPane.showInputDialog("Ingrese un numero"));
for(i=1;i<=numero;i++){
ac=ac*i;

}
JOptionPane.showMessageDialog(null,"EL FACTORIAL DE " + numero + " es "+ ac);

También podría gustarte