예제 #1
0
        public void BigIntegerFactorial()
        {
            Assert.AreEqual(BigInteger.One, GeneralMath.FactorialBigInteger(0));
            var r = new Random();

            for (int i = 0; i < 16; i++)
            {
                Assert.Throws <ArgumentException>(() => GeneralMath.FactorialBigInteger(-r.Next()));
            }

            BigInteger currentResult = 1;

            for (int multiplier = 1; multiplier <= 100; multiplier++)
            {
                currentResult *= multiplier;
                Assert.AreEqual(currentResult, GeneralMath.FactorialBigInteger(multiplier));
            }
        }