Skip to content

Instantly share code, notes, and snippets.

@andytudhope
Created November 16, 2015 08:21
Show Gist options
  • Select an option

  • Save andytudhope/6d592a234e4fe1ea446d to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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