Skip to content

Instantly share code, notes, and snippets.

@piqueen314
Created December 11, 2015 00:44
Show Gist options
  • Save piqueen314/e8a3351ef1ae1e5b0a17 to your computer and use it in GitHub Desktop.
Save piqueen314/e8a3351ef1ae1e5b0a17 to your computer and use it in GitHub Desktop.
Return the factorial of the provided integer.
// 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