Last active
July 30, 2016 17:22
-
-
Save PatrickEifler/31480215a3dd3f24402cb3159ef3f410 to your computer and use it in GitHub Desktop.
Handy Function Examples
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
# Easy Recursive Functions | |
## Factorial | |
``` | |
const factorial = n => n > 1 ? n * factorial(n-1) : 1; | |
``` | |
## Fibonacci | |
``` | |
const fibonacci = n => n < 2 ? n : (fibonacci(n-1) + fibonacci(n-2)); | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment