Skip to content

Instantly share code, notes, and snippets.

@jineeshjohn
Created August 19, 2013 09:03
Show Gist options
  • Save jineeshjohn/6267081 to your computer and use it in GitHub Desktop.
Save jineeshjohn/6267081 to your computer and use it in GitHub Desktop.
fibonacci in JavaScript with iterative approach
function fibo(n) {
var f = [];
for (var i = 0; i < n; i++ ) {
var item = (i < 2) ? i : f[i-1] + f[i-2];
f.push(item);
}
return f;
}
var fibos = fibo(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment