Skip to content

IxI-Enki/Uebung-030

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Uebung-30 -- Fakultät


SPOILER

using System;

namespace Fakultät
{
  internal class Program
  {
    static void Main()
    {
      string userInput;
      int userInteger,
          output = 1;
      Console.Write("\n         Fakultätrechner " +
                    "\n================================" +
                    "\n Geben Sie eine ganze Zahl ein." +
                    "\n ");
      userInput = Console.ReadLine();
      int.TryParse(userInput, out userInteger);

      Console.Write($"{userInteger}! ergibt: ");
      if (userInteger == 0)
      {
        output = 1;
      }
      else
      {
        for (userInteger = userInteger; userInteger > 0; userInteger--)
        {
          output = userInteger * output;
        }
      }
      Console.Write($" {output} ");

      Console.Write("\nZum Beenden bitte Eingabetaste drücken ...");
      Console.ReadLine();
      Console.Clear();
    }
  }
}