Example #1
0
        // starts a call to fibonacci and captures start/end times
        TimeData StartFibonacci(int n)
        {
            // create a TimeData object to store start/end times
            var result = new TimeData();

            AppendText($"Calculating Fibonacci({n})");
            result.StartTime = DateTime.Now;
            long fibonacciValue = Fibonacci(n);

            result.EndTime = DateTime.Now;

            AppendText($"Fibonacci({n}) = {fibonacciValue}");
            double minutes =
                (result.EndTime - result.StartTime).TotalMinutes;

            AppendText($"Calculation time = {minutes:F6} minutes\r\n");

            return(result);
        }
Example #2
0
        // starts a call to factorial and captures start/end times
        TimeData StartFactorial(int n)
        {
            // create a TimeData object to store start/end times
            var result = new TimeData();

            AppendText($"Calculating Factorial({n})");
            result.StartTime = DateTime.Now;
            BigInteger factorialValue = Factorial(n);

            result.EndTime = DateTime.Now;

            AppendText($"Factorial({n}) = {factorialValue}");
            double minutes =
                (result.EndTime - result.StartTime).TotalMinutes;

            AppendText($"Calculation time = {minutes:F6} minutes\r\n");

            return(result);
        }
Example #3
0
        // starts a call to rolldie and captures start/end times
        TimeData StartRollDie(long n)
        {
            // create a TimeData object to store start/end times
            var result = new TimeData();

            AppendText($"Calculating RollDie({n})");
            result.StartTime = DateTime.Now;
            BigInteger highestNoValue = RollDie(n);

            result.EndTime = DateTime.Now;

            AppendText($"Number appearing Highest times in Die Roll({n}) = {highestNoValue}");
            double minutes =
                (result.EndTime - result.StartTime).TotalMinutes;

            AppendText($"Calculation time = {minutes:F6} minutes\r\n");

            return(result);
        }