public void Verify_Fibonacci_Terms_That_Do_Not_Exceed_OneHundred()
        {
            List <long> expected = new List <long> {
                1, 2, 3, 5, 8, 13, 21, 34, 55, 89
            };

            List <long> series = FibonacciSeriesCalculator.GetFibonacciSeriesWithValuesNotExceeding(100);

            CollectionAssert.AreEquivalent(expected, series);
        }
        public void Verify_First_Ten_Fibonacci_Terms()
        {
            List <long> expected = new List <long> {
                1, 2, 3, 5, 8, 13, 21, 34, 55, 89
            };

            List <long> series = FibonacciSeriesCalculator.GetFibonacciSeries(10);

            CollectionAssert.AreEquivalent(expected, series);
        }
Exemple #3
0
        public long Solve(long solveFor)
        {
            List <long> series = FibonacciSeriesCalculator.GetFibonacciSeriesWithValuesNotExceeding(solveFor);
            long        sum    = 0;

            foreach (long element in series)
            {
                if (element % 2 == 0)
                {
                    sum += element;
                }
            }

            return(sum);
        }