예제 #1
0
 public static ulong Compute(ulong n)
 {
     if (n == 0)
     {
         return(1);
     }
     return(n * Factorial.Compute(n - 1));
 }
예제 #2
0
        static void ForAllExample()
        {
            var numbers = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8
            };

            numbers.AsParallel().ForAll(x => Console.WriteLine("{0}! = {1}", x, Factorial.Compute(x)));
        }
    public void Compute_ReturnsCorrectResult(int n, int expectedResult)
    {
        var sut = new Factorial();

        Assert.AreEqual(expectedResult, sut.Compute(n));
    }