Last active
August 29, 2015 14:25
-
-
Save alexandrebvd/d76803dce96861c199a3 to your computer and use it in GitHub Desktop.
4.Bonfire: Factorialize a Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorialize(num) { | |
if (num === 0) { | |
return 1; | |
} else { | |
for (var i = num; i > 1; i--) { | |
num *= (i-1); | |
} | |
return num; | |
} | |
} | |
factorialize(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment