Find factorial of a number in C# using recursion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FactorialNumber\_Recursion
{
class Program
{
static void Main(string\[\] args)
{
int number =0;
Console.WriteLine("Enter the number");
number = int.Parse(Console.ReadLine());
int fact = Factorial(number);
Console.WriteLine("{0} Factorial is {1}", number, fact);
}
public static int Factorial(int num)
{
if (num ==0)
{
return 1;
}
else
{
return (num \* Factorial(num - 1));
}
}
}
}
Output: Enter the number 5 5 Factorial is 120