CSharp examples for Data Structure Algorithm:Factorial
Calculate Factorial with recursive method
using System;//w ww . j a v a 2 s . c o m class MyMath { public static long Factorial (long number) { if (number == 0) return 1; else return (number * Factorial (number - 1)); } } class TestFactorial { public static void Main() { Console.WriteLine("4 factorial is {0}", MyMath.Factorial(4)); } }