Factorial is a positive number which is the product of all number less than or equal to that positive number.
For example:
0! = 1
1! = 1
2! = 2 * 1! = 2
3! = 3 * 2! = 6
…
n! = n * (n – 1)!
Here is the sample code to calculate Factorial using both loop and recursion using c#.