Created
May 25, 2020 20:50
-
-
Save Quantalabs/3f47608c69585bd2e9ccde5de0a39bad to your computer and use it in GitHub Desktop.
Outputs a number in the fibbonacci sequence in the console. Read about the fibbonacci sequence at https://en.wikipedia.org/wiki/Fibonacci_number
This file contains 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 calc = function (amount) { | |
var a = 1 //change the two variables to get a different fibbonacci sequence | |
var b = 1 | |
for(var i = 0; i < amount; i++) { | |
var i = a+b | |
b = a | |
a = i | |
} | |
console.log(a) //outputs the 'amount' number in the fibbonacci sequence. | |
} | |
calc(100) //how many numbers you want to produce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment