(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));
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme