Factorial Simplified using lambda






4.20/5 (7 votes)
Factorial Simplified using lambda
Here is a trick which uses recursion in Lambda:
class Factorial
{
static void Main()
{
//Lambada Expression
Func<int,int> call = null;
call = x => x * (x == 1 ? 1 : call(x - 1));
Console.WriteLine(call(5));
Console.ReadLine();
}
}