jae-l
1/2/2017 - 4:23 PM

Calculate the factorial of a number. From Fundamentals of Computer Programming with C# http://www.introprogramming.info/wp-content/uploads/2

int n = int.Parse(Console.ReadLine());
decimal factorial = 1;

while (true)
{
  if (n <= 1)
  {
    break;
  }
  factorial *= n;
  n--;
}
Console.WriteLine("n! = " + factorial);

// 5
// n! = 120