Click here to Skip to main content
15,887,477 members
Articles / Programming Languages / C#

Calculate the Factorial of an Integer in C#

Rate me:
Please Sign up or sign in to vote.
4.33/5 (6 votes)
4 Oct 2011CPOL 53.6K   2  
It could be done using Recursive Lambda Expression, for example,class Program{ static Func Factorial = x => x < 0 ? -1 : x == 1 || x == 0 ? 1 : x * Factorial(x - 1); static void Main(string[] args) { Console.WriteLine(Factorial(5)); }}(The code...

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia

Comments and Discussions