Skip to content

Instantly share code, notes, and snippets.

@saliksyed
Created January 8, 2020 21:56
Show Gist options
  • Save saliksyed/a6bbb63f512803f5c0f0d4efdb6a544d to your computer and use it in GitHub Desktop.
Save saliksyed/a6bbb63f512803f5c0f0d4efdb6a544d to your computer and use it in GitHub Desktop.
Fibonacci sequence algorithm in Javascript
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))
@saliksyed
Copy link
Author

Hi Fahad! :) @fahdie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment