Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main()
- {
- Console.Write("Enter the integer to calculate the factorial for: ");
- int num = int.Parse(Console.ReadLine());
- int factorial = Factorial(num);
- Console.WriteLine("{0}! = {1}", num, factorial);
- }
- static int Factorial(int num)
- {
- if (num == 0)
- {
- return 1;
- }
- else
- {
- return num * Factorial(num - 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement