Skip to content

Instantly share code, notes, and snippets.

Created December 7, 2015 23:23
Show Gist options
  • Save anonymous/b2b0aa218afbdb10c293 to your computer and use it in GitHub Desktop.
Save anonymous/b2b0aa218afbdb10c293 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/thetinybeaker 's solution for Bonfire: Factorialize a Number
// Bonfire: Factorialize a Number
// Author: @thetinybeaker
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function factorialize(num) {
if (num === 0){
return 1;
}
else if (num < 0){
return -1;
}
else {
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