Skip to content

Instantly share code, notes, and snippets.

@EvilFreelancer
Created September 6, 2022 09:18
Show Gist options
  • Select an option

  • Save EvilFreelancer/46efb31f6913fe075556e3b358f49595 to your computer and use it in GitHub Desktop.

Select an option

Save EvilFreelancer/46efb31f6913fe075556e3b358f49595 to your computer and use it in GitHub Desktop.
Fibonacci Sequence In JavaScript
const max = process.argv.slice(2);
const fibonacci = n => {
let a = 0, b = 1, c = n;
console.log(a);
console.log(b);
for(let i = 2; i <= n; i++) {
c = a + b;
console.log(c);
a = b;
b = c;
}
return c;
};
fibonacci(max);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment