コード例 #1
0
 /// <summary>
 /// Run solution for problem 20.
 /// </summary>
 /// <param name="factorialInput">Factorial input.</param>
 /// <returns>Sum of factorial result's digits.</returns>
 public static int Run(int factorialInput)
 {
     return(LargeNumberMath.GetFactorial(factorialInput).ToCharArray().Aggregate(0, (sum, digit) =>
     {
         return sum + int.Parse(digit.ToString());
     }));
 }
コード例 #2
0
        public void GetFactorial_Returns_Factorial_Result()
        {
            var number = 10;
            var expected = Enumerable.Range(1, number).Aggregate(1, (factorial, number) => factorial * number);

            LargeNumberMath.GetFactorial(number).Should().Be(expected.ToString());
        }