Created
January 8, 2020 21:56
-
-
Save saliksyed/a6bbb63f512803f5c0f0d4efdb6a544d to your computer and use it in GitHub Desktop.
Fibonacci sequence algorithm in Javascript
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
function fibonacci(num){ | |
var a = 1, b = 0, temp; | |
while (num >= 0){ | |
temp = a; | |
a = a + b; | |
b = temp; | |
num--; | |
} | |
return b; | |
} | |
console.log(fibonacci(10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Fahad! :) @fahdie