static private ulong fact(ulong a)
factorial = factorial * i;
static private double DectoPer(double a)
static private double PertoDec(double a)
static private ulong nPr(ulong n, ulong r)
ulong nrfact = fact(n - r);
static private ulong nCr(ulong n, ulong r)
ulong nrfact = fact(n - r);
ulong rnrfact = rfact * nrfact;
public static void Main()
while (restart != "q" && restart != "Q")
Console.WriteLine("Please choose which option you would like to calculate");
Console.WriteLine("Press 1 for factorial, 2 to convert from decimal to percent, 3 to convert from percent to decimal, 4 to calculate the permutation of numbers from a set, and 5 to calculate the combination of numbers from a set.");
string choice = Console.ReadLine();
Console.WriteLine("What would you like to calculate the factorial of?");
string num = Console.ReadLine();
if (ulong.TryParse(num, out number))
ulong final = fact(number);
Console.WriteLine("The factorial of " + number + " is " + final + "");
Console.WriteLine("Your value that you entered was not a ulong, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("What number would you like to convert from decimal to percent?");
string num = Console.ReadLine();
if (double.TryParse(num, out number))
double final = DectoPer(number);
Console.WriteLine(number + " as a percentage is " + final + "%");
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("What number would you like to convert from percent to decimal?");
string num = Console.ReadLine();
if (double.TryParse(num, out number))
double final = PertoDec(number);
Console.WriteLine(number + "% as a decimal is " + final + "");
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("How many objects are in the set?");
string num = Console.ReadLine();
if (ulong.TryParse(num, out number))
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("How many objects are you selecting from the set?");
string num2 = Console.ReadLine();
if (ulong.TryParse(num2, out number2))
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
double final = nPr(number, number2);
Console.WriteLine("Your permutation is " + final + "");
Console.WriteLine("How many objects are in the set?");
string num = Console.ReadLine();
if (ulong.TryParse(num, out number))
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("How many objects are you selecting from the set?");
string num2 = Console.ReadLine();
if (ulong.TryParse(num2, out number2))
Console.WriteLine("Your value that you entered was not a double, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
double final = nCr(number, number2);
Console.WriteLine("Your combination is " + final + "");
Console.WriteLine("Your choice was not valid, please try again.");
Console.WriteLine("Press any key to try again.");
string cont = Console.ReadLine();
Console.WriteLine("Press 'q' to quit or anything else to restart.");
restart = Console.ReadLine();