Last active
November 6, 2015 19:20
-
-
Save patrickbrandt/cc73ff1783c6fa7dc7f9 to your computer and use it in GitHub Desktop.
Add even Fibonacci numbers up to the Nth number provided. Because.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sumEvenFib = function(number) { | |
var _internalSumEvenFib = function(current, fib, num, sum) { | |
return (num <= 1) ? sum : _internalSumEvenFib(fib, current + fib, --num, (!(fib % 2) ? sum + fib : sum)); | |
}; | |
return _internalSumEvenFib(1, 1, number, 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment