Skip to content

Instantly share code, notes, and snippets.

@AlexCheese
Created February 7, 2019 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCheese/372d0329131014e9542cf07eaaba45ee to your computer and use it in GitHub Desktop.
Save AlexCheese/372d0329131014e9542cf07eaaba45ee to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Factorial
{
class Program
{
static void Main(string[] args)
{
double input, output;
string text;
while (true)
{
Console.WriteLine("Enter a number: ");
text = Console.ReadLine();
if (double.TryParse(text, out input))
{
output = 1f;
for (double i = input; i > 0; i--)
{
output *= i;
}
Console.WriteLine("Factorial of " + input + ": " + output);
}
else
{
Console.WriteLine("error");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment