Created
February 7, 2019 02:52
-
-
Save AlexCheese/372d0329131014e9542cf07eaaba45ee to your computer and use it in GitHub Desktop.
This file contains 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; | |
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