Sum All Odd Fibonacci Numbers
Given a positive integer num
, return the sum of all odd Fibonacci numbers that are less than or equal to num
.
The first two numbers in the Fibonacci sequence are 0 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first seven numbers of the Fibonacci sequence are 0, 1, 1, 2, 3, 5 and 8.
For example, sumFibs(10)
should return 10
because all odd Fibonacci numbers less than or equal to 10
are 1, 1, 3, and 5.
Tests
- Waiting: 1.
sumFibs(1)
should return a number. - Waiting: 2.
sumFibs(1000)
should return 1785. - Waiting: 3.
sumFibs(4000000)
should return 4613732. - Waiting: 4.
sumFibs(4)
should return 5. - Waiting: 5.
sumFibs(75024)
should return 60696. - Waiting: 6.
sumFibs(75025)
should return 135721.
/** * Your test output will go here */