Skip to content

Instantly share code, notes, and snippets.

@MinimumViablePerson
Last active December 31, 2019 12:26
Show Gist options
  • Save MinimumViablePerson/da1c18d973cffce86c977d3d0233d058 to your computer and use it in GitHub Desktop.
Save MinimumViablePerson/da1c18d973cffce86c977d3d0233d058 to your computer and use it in GitHub Desktop.
Recursion from Scratch - fibonacci
const fibonacci = n => {
// The 0th fibonacci number is: 0
if (n === 0) return 0
// The 1st fibonacci number is: 1
if (n === 1) return 1
// The Nth fibonacci number is:
// The fibonacci of N - 1 plus the fibonacci of N - 2
return fibonacci(n - 1) + fibonacci(n - 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment