Skip to content

Instantly share code, notes, and snippets.

@mikepenzin
Created February 28, 2017 15:03
Show Gist options
  • Save mikepenzin/04c26df38f2c2ac70f8c91666a438e6a to your computer and use it in GitHub Desktop.
Save mikepenzin/04c26df38f2c2ac70f8c91666a438e6a to your computer and use it in GitHub Desktop.
Function will output the value of factorial.
// 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