Created
January 9, 2019 14:25
-
-
Save Tombarr/952c950c63579977eeebcd788f345f65 to your computer and use it in GitHub Desktop.
Fibonacci 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
const fibonacci = (n) => { | |
if (n < 0) { | |
return null; | |
} else if (n == 0 || n == 1) { | |
return 1; | |
} else { | |
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