Created
October 9, 2015 13:49
-
-
Save SajjadArifGul/33842c2eae651aa9b76d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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