Problem 2: Even Fibonacci Numbers
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed n
, find the sum of the even-valued terms.
Tests
- Waiting: 1.
fiboEvenSum(10)
should return a number. - Waiting: 2. Your function should return an even value.
- Waiting: 3. Your function should sum the even-valued Fibonacci numbers:
fiboEvenSum(8)
should return 10. - Waiting: 4.
fiboEvenSum(10)
should return 10. - Waiting: 5.
fiboEvenSum(34)
should return 44. - Waiting: 6.
fiboEvenSum(60)
should return 44. - Waiting: 7.
fiboEvenSum(1000)
should return 798. - Waiting: 8.
fiboEvenSum(100000)
should return 60696. - Waiting: 9.
fiboEvenSum(4000000)
should return 4613732.
/** * Your test output will go here */