Skip to content

Instantly share code, notes, and snippets.

@Blizzardo1
Created June 13, 2023 06:14
Show Gist options
  • Save Blizzardo1/efefd115367260aae48fcf087206d41b to your computer and use it in GitHub Desktop.
Save Blizzardo1/efefd115367260aae48fcf087206d41b to your computer and use it in GitHub Desktop.
using System.Numerics;
namespace FactorialExample;
internal static class Program
{
private static BigInteger Factorial(int number) {
if (number == 0) return 1;
return number * Factorial(number - 1);
}
private static void Main(string[] args)
{
Console.Write("Please enter a number greater than zero: ");
if(!int.TryParse(Console.ReadLine(), out int number))
{
Console.WriteLine("Not a valid number!");
return;
}
BigInteger factorial = Factorial(number);
Console.WriteLine($"The Factorial of {number} is {factorial}.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment