Skip to content

Instantly share code, notes, and snippets.

@Quantalabs
Created May 25, 2020 20:50
Show Gist options
  • Save Quantalabs/3f47608c69585bd2e9ccde5de0a39bad to your computer and use it in GitHub Desktop.
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
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