Don't like ads? PRO users don't see any ads ;-)
Guest

RecursionFactorial

By: bsudhir6 on May 15th, 2012  |  syntax: C#  |  size: 0.63 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace RecursionFactorial
  7. {
  8.     class Program
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             for (long counter = 1; counter <= 10; counter++)
  13.                 Console.WriteLine("{0}! = {1}", counter, Factorial(counter));
  14.         }//end Main
  15.  
  16.         public static long Factorial( long number){
  17.                
  18.                 if( number <= 1)
  19.                 return 1;
  20.  
  21.                 else
  22.                 return number * Factorial(number - 1);
  23.                
  24.         }//end method Factorial
  25.     }//end class Program
  26. }//end RecursionFactorial