/// <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()); })); }
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()); }