diff --git a/app.js b/app.js index ad9a93a7..caa45b9a 100644 --- a/app.js +++ b/app.js @@ -1 +1,23 @@ 'use strict'; + +const memo = new Map(); +memo.set(0,0); +memo.set(1,1); +function fib(n){ + if (memo.has(n)){ + return memo.get(n); + } + else{ + const value = fib(n-1)+fib(n-2); + memo.set(n, value); + return value; + } +}; + +const length = 100; +for (let i=0; i<=length; i++){ + console.log(fib(i)); +}; + + +