7 kyu
Fast Fibonacci
875nrgarg
Description:
Fast Fibonacci
The generic implementation of the fibonacci algorithm is usually something like the following
function fib(num) {
if (num < 2) return num;
return fib(num - 1) + fib(num - 2);
}
Now thats all and well and good but that function isn't too efficient. If I wanted to get the 1000th number in the series, I'd have to wait... days? maybe years?
Your task
Write a more efficient fibonacci function that can calculate the 1000th+ number series without breaking a sweat. Read up on tail call optimization for some help.
Starting values
fib(0) = 0;
fib(1) = 1;
Functional Programming
Algorithms
Similar Kata:
Stats:
Created | Jun 5, 2015 |
Published | Jun 5, 2015 |
Warriors Trained | 1821 |
Total Skips | 112 |
Total Code Submissions | 2203 |
Total Times Completed | 875 |
JavaScript Completions | 875 |
Total Stars | 35 |
% of votes with a positive feedback rating | 87% of 176 |
Total "Very Satisfied" Votes | 140 |
Total "Somewhat Satisfied" Votes | 25 |
Total "Not Satisfied" Votes | 11 |