title: C# to calculate factorial
body: <p>I have this code that gets an input from the user and calculate its factorial and the factorial for less than the input number, but I keep getting the factorial for the first number only and the rest is 0. It should be like this: For example, if the input is 5:</p>
  
  <p>5! = 120</p>
  
  <p>4! = 24</p>
  
  <p>3! = 6</p>
  
  <p>2! = 4</p>
  
  <p>1! = 1</p>
  
  <p>How do I make the loop go throw all the numbers below the input number?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace multiple_factorials
  {
      class Program
      {
          static void Main(string[] args)
          {
              int num, n;
  
              Console.WriteLine(".....................[Application 1].....................\n\n");
              Console.WriteLine("Please enter a number to get its factorial: ");
              num = Convert.ToInt32(Console.ReadLine());
  
              n = num; // Assign n to num
  
              while (num &gt; 0)
              {
                  for (int i = n - 1; i &gt; 0; i--)
                  {
                     n *= i;
                  }
                  Console.WriteLine("Factorial of {0}! = {1}\n", num, n);
                  num--;
              }
          }
      }
  }
  </code></pre>