Advertisement
LightProgrammer000

Fatorial [Cálculo Rápido]

Dec 4th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. // Bibliotecas
  2. using System;
  3.  
  4. // Programa
  5. namespace EX_09
  6. {
  7.     // Classe
  8.     public class Classe
  9.     {
  10.         // Método Principal
  11.         public static void Main(string [] args)
  12.         {
  13.             // Variáveis
  14.             int num;
  15.             int i = 1;
  16.             int fat = 1;
  17.            
  18.             // Entrada de Dados
  19.             Console.Clear();
  20.             Console.Write("\n - Digite o Número: ");
  21.             num = int.Parse( Console.ReadLine() );// Conversão (Int) <-- (String)
  22.        
  23.             // Estrutura de Repetição
  24.             while( i <= num )
  25.             {
  26.                 fat *= i;
  27.                 i++;
  28.             }
  29.  
  30.             // Apresentação de Dados
  31.             Console.Clear();
  32.             Console.Write("\n -------------------- ");
  33.             Console.Write("\n - Fatorial: " + fat );
  34.             Console.Write("\n -------------------- \n\n");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement