Exemplo n.º 1
0
 public static ulong Compute(ulong n)
 {
     if (n == 0)
     {
         return(1);
     }
     return(n * Factorial.Compute(n - 1));
 }
Exemplo n.º 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));
    }