Created
February 28, 2017 15:03
-
-
Save mikepenzin/04c26df38f2c2ac70f8c91666a438e6a to your computer and use it in GitHub Desktop.
Function will output the value of factorial.
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
// f(0); // Outputs 0 | |
// f(5); // Outputs 120 | |
function f(n) { | |
// ? stands for if statement - if n = 1 or less will return - n. if n > 1, then n * f(n-1) | |
// f(n); is recursion function | |
return ((n > 1) ? n * f(n-1) : n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment