Skip to content

Instantly share code, notes, and snippets.

  • Save twhite96/ed3624b7e46fbb9c76bf to your computer and use it in GitHub Desktop.
Save twhite96/ed3624b7e46fbb9c76bf to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/twhite96 's solution for Bonfire: Factorialize a Number
// Bonfire: Factorialize a Number
// Author: @twhite96
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number?solution=function%20factorialize(num)%20%7B%0A%20%20if%20(num%20%3D%3D%3D%200)%20%7B%0A%20%20%20%20return%201%3B%0A%20%20%7D%0A%20%20%20%20return%20num%20*%20factorialize(num%20-%201)%3B%0A%7D%0A%0Afactorialize(5)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function factorialize(num) {
if (num === 0) {
return 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