Created
March 21, 2016 09:04
-
-
Save sedera-tax/3bce077e607268c0a335 to your computer and use it in GitHub Desktop.
Fibonacci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i; | |
var p = 100; | |
var fib = []; // Initialize array! | |
fib[0] = 0; | |
fib[1] = 1; | |
for(i=2; i<=p; i++) | |
{ | |
// Next fibonacci number = previous + one before previous | |
// Translated to JavaScript: | |
fib[i] = fib[i-2] + fib[i-1]; | |
alert(fib[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment