Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robertsheacole/4dd0c508d0d98862e86f to your computer and use it in GitHub Desktop.
Save robertsheacole/4dd0c508d0d98862e86f to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/robertsheacole 's solution for Bonfire: Factorialize a Number
// Bonfire: Factorialize a Number
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function factorialize(num) {
//Check is num paramater is equal to 0. If so return 1, otherwise answer will be 0.
if(num === 0){
return 1;
}
//This is the main part of the function. It multiplies the paramater by the function paramater minus 1. So, (5 * (5 - 1))
return num * factorialize(num - 1);
}
factorialize(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment