Factorial program in C#

Factorial of n is the product of all positive descending integers. Example: 4! = 4*3*2*1 = 24

Factorial is the most commonly asked programming question. Let’s look at the solutions:

Using while loop:

The simplest solution is to calculate factorial using the while loop . Time complexity of this solution O(n).

Using Recursion