title: Calculating factorials in C# using loops
body: <p>This is what I have so far:</p>
  
  <pre><code>namespace factorials
  {
      class Program
      {
          static void Main(string[] args)
          {
              int number;
  
              do
              {
                  Console.WriteLine("What non-negative integer do you want to factorial?");
                  while (!int.TryParse(Console.ReadLine(), out number))
                      Console.WriteLine("Please enter a whole number only");
                  calculate(ref number);
              } while (number &gt;= 0);
              Console.WriteLine("Please enter a non-negative number");
  
          }
          static void calculate(ref int number)
          {
              int factorial;
              int counter;
  
              for (counter = number; counter &lt;= number; counter++)
              {
                  factorial = number * number;
                  Console.WriteLine("The factorial of {0} is {1}", number, factorial);
              }
  
      }
      }
      }
  </code></pre>
  
  <p>Right now it just gives me the square of the numbers, not the factorial of them.  How do I make it repeat the number of times as the input so it results in a factorial?</p>
  
  <p>Also I am not sure if it's necessary to limit the program to non-negative integers only but if I want to that part is just ending the program right there instead of looping back to the beginning.</p>