public void TestFactorialOfOneIsOne()
        {
            // act
            BigInteger result1 = BigIntegerMathLib.Factorial1(1);
            BigInteger result2 = BigIntegerMathLib.Factorial2(1);

            // assert
            BigInteger one = 1;

            Assert.AreEqual(one, result1);
            Assert.AreEqual(one, result2);
        }
        public void TestBothVersionsOfFactorialAreEqual()
        {
            for (BigInteger n = 0; n < 100; n++)
            {
                // act
                BigInteger factorial1 = BigIntegerMathLib.Factorial1(n);
                BigInteger factorial2 = BigIntegerMathLib.Factorial2(n);

                // assert
                Assert.AreEqual(factorial1, factorial2);
            }
        }
Esempio n. 3
0
        static void Main()
        {
            BigInteger factorial1000 = BigIntegerMathLib.Factorial2(1000);
            BigInteger fibonacci1000 = BigIntegerMathLib.Fibonacci2(1000);

            string message1 = string.Format("\nFactorial(1000) = \n{0}", factorial1000);

            Console.WriteLine(message1);

            string message2 = string.Format("\nFibonacci(1000) = \n{0}", fibonacci1000);

            Console.WriteLine(message2);

            const string file     = "FactorialAndFibonacci.txt";
            string       contents = string.Format("{0}{1}", message1, message2);

            File.WriteAllText(file, contents);

            Console.ReadKey();
        }
 public void TestFactorial2OfNegativeNumberThrowsArgumentException()
 {
     // assert
     Assert.That(() => BigIntegerMathLib.Factorial2(-1), Throws.TypeOf <ArgumentException>());
 }