using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
Console.Write("Enter a number: ");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Factorial of {0} is: {1}", n, recursiveFactorial(n));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
static long recursiveFactorial(int n)
{
if (n == 0)
return 1;
else
return (n * recursiveFactorial(n - 1));
}
}
}
/*
run:
Enter a number: 5
Factorial of 5 is: 120
*/