Edited at

フィボナッチ数列演習js

More than 5 years have passed since last update.

(function (scope) {

var _memo = [1, 1];

function fib(n) {
var i;

if (!_memo[n - 1]) {
for (i = _memo.length; i < n; i += 1) {
_memo[i] = _memo[i - 2] + _memo[i - 1];
}
}
return _memo[n - 1];
}

scope.fib = fib;

}(this));