Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- */
- package com.mycompany.problema1;
- /**
- *
- * @author ianto
- */
- import java.util.*;
- public class Problema1 {
- 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();
- 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