Exemplo n.º 1
0
 public void Fibonacci2RecursiveMemoizationCompleteTest2ErrorNegativeNumber()
 {
     try
     {
         Fibonacci2RecursiveMemoizationComplete.Fibonacci(-1);
     }
     catch
     {
         Assert.IsTrue(true);
         return;
     }
     Assert.Fail();
 }
Exemplo n.º 2
0
        public void Fibonacci2RecursiveMemoizationCompleteTest1()
        {
            // Build the expected array.
            var expected = new[] { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181 };

            // Calculate the first 20 Fibonacci numbers.
            var actual = new int[20];

            for (var n = 0; n < actual.Length; n++)
            {
                actual[n] = Fibonacci2RecursiveMemoizationComplete.Fibonacci(n);
            }

            CollectionAssert.AreEqual(actual, expected);
        }