Created
December 11, 2015 00:44
-
-
Save piqueen314/e8a3351ef1ae1e5b0a17 to your computer and use it in GitHub Desktop.
Return the factorial of the provided integer.
This file contains hidden or 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
// Bonfire: Factorialize a Number | |
// Author: @piqueen314 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function factorialize(num) { | |
var fac=1; | |
if (num ===0){ | |
return fac; | |
} | |
for(var i=1; i<=num; i++) | |
{ | |
fac = i*fac; | |
} | |
return fac; | |
} | |
factorialize(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment