/*1. FATORIAL Exemplo: 5! = 1 * 2 * 3 * 4 * 5 = 120*/ import java.io.*; public class Fatorial { public static void main(String[]args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try { long fat; int n = 0; int aux; String linha = null; fat= 1; System.out.print("Digite o Numero a Ser Calculado: "); linha = in.readLine(); n = Integer.parseInt(linha); aux = n; while (n >= 1) { fat = fat * n; n = n - 1; } System.out.println(" "); System.out.print("O Fatorial de " + aux +" e: " + fat); System.out.println(" "); } catch(IOException e) { System.out.println("Erro de leitura"); } } } /* ALGORITMO FATORIAL inicio; inteiro: N,fat; leia: ( N ); fat <-- 1; enquanto( N > = 1) faça fat <-- fat * N; N <-- N - 1; fim enquanto; escreva( fat ); fim; */