- 1

What is a more efficient way to do this? After 33 I can only get a return value of zero :/

using System.IO; using System; class Program { static int count=0; /*Creation of the Fact() method*/ static uint Fact(uint num) { if (num == 1){ return 1; } count++; return num*Fact(num-1); } /*Asks for input, reads the input, then returns a value*/ static void InOut() { Console.WriteLine("Give a number to return the factorial: "); uint input = Convert.ToUInt32(Console.ReadLine()); var x = Fact(input); Console.WriteLine("Factorial: {0}", x); Console.WriteLine("The Fact() Loop Was Executed {0} Times", count); count = 0; Console.ReadKey(); } /*session wake method*/ static void Suspend() { bool sesh; do { InOut(); Console.WriteLine(">>>If you would like to exit the loop, simply type \"exit\"<<<"); string SeshCheck = Console.ReadLine(); if(SeshCheck=="exit"){ sesh = false; break; } else{ sesh = true; continue; } } while(sesh==true); } /*Main Method*/ static void Main(string[] args) { Suspend(); } }

15th Feb 2017, 3:32 PM
Nick
Nick - avatar
1 Antwort
0
Could you use ulong instead of uint?
15th Feb 2017, 3:41 PM
Paul Shaddick
Paul Shaddick - avatar