Skip to content

Instantly share code, notes, and snippets.

@andytudhope
Created November 16, 2015 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andytudhope/6d592a234e4fe1ea446d to your computer and use it in GitHub Desktop.
Save andytudhope/6d592a234e4fe1ea446d to your computer and use it in GitHub Desktop.
Free Code Camp Bonfire
function factorialize(num) {
if (num === 0 || num === 1) {
return 1;
}
return num * factorialize(num-1);
}
factorialize(5);
@andytudhope
Copy link
Author

This snippet uses a recursive function to calculate the factorial of any number passed to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment