Added bottom up DP implementation of Fibonacci

This commit is contained in:
Lee Southerst
2017-09-28 12:59:16 -04:00
parent cedbe13111
commit 6aaa663688

View File

@ -0,0 +1,14 @@
function fib(n) {
var table = [];
table.push(1);
table.push(1);
for (var i = 2; i < n; ++i) {
table.push(table[i - 1] + table[i - 2]);
}
console.log("The %dth fibonacci number is %d", n, table[n - 1]);
}
fib(200);
fib(5);
fib(10);