Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Programa1 {
- public static void main(String[] args) {
- int numero;
- int factorial = 1;
- int contador = 2;
- Scanner entrada = new Scanner(System.in);
- System.out.println("-FACTORIAL DE UN NUMERO-");
- System.out.println("Ingrese un numero entero");
- numero = entrada.nextInt();
- //while(contador <= num) {
- //factorial *= contador;
- //contador ++;
- //}
- //if(numero == 0 && numero == 1){
- //System.out.println("Por Defenicion");
- //System.out.println("0! = 1 y 1! = 1");
- //}else {
- for(int i = numero; i>0; i--) {
- factorial *= i;
- }
- //}
- if(numero > 1) {
- System.out.println("\tRESULTADO");
- System.out.println("\t" + numero + "! = " + factorial);
- }else {
- System.out.println("Por Defenicion");
- System.out.println("0! = 1 y 1! = 1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement