Calculate Factorial Number with Iterative - CSharp Data Structure Algorithm

CSharp examples for Data Structure Algorithm:Factorial

Description

Calculate Factorial Number with Iterative

Demo Code

using System;//from  w ww  . j  a  v  a  2 s .  c o  m
class Math
{
   public static long Factorial(long number)
   {
      long factorial = 1;
      for(long i = number; i >= 1; i--)
      {
         factorial *= i;
      }
      return factorial;
   }
}
class Tester
{
   public static void Main()
   {
      Console.WriteLine("4! = {0}", Math.Factorial(4));
   }
}

Result


Related Tutorials