Skip to content

Instantly share code, notes, and snippets.

@SajjadArifGul
Created October 9, 2015 13:49
Show Gist options
  • Save SajjadArifGul/33842c2eae651aa9b76d to your computer and use it in GitHub Desktop.
Save SajjadArifGul/33842c2eae651aa9b76d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace factorial
{
class factor
{
public int factorial(int value)
{
int fac = 1;
if (value > 1)
{
fac = value * factorial(value - 1);
}
return fac;
}
}
class Program
{
static void Main(string[] args)
{
factor f = new factor();
Console.WriteLine("Enter value to get factorial");
int value = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Factorial : {0}", f.factorial(value));
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment