Last active
December 31, 2019 12:26
-
-
Save MinimumViablePerson/da1c18d973cffce86c977d3d0233d058 to your computer and use it in GitHub Desktop.
Recursion from Scratch - fibonacci
This file contains 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
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