Skip to content

Instantly share code, notes, and snippets.

@shahrzadmn
Last active December 8, 2015 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahrzadmn/3485b15ae170003a5dca to your computer and use it in GitHub Desktop.
Save shahrzadmn/3485b15ae170003a5dca to your computer and use it in GitHub Desktop.
Finding factorial of an integer by using for loop in JavaScript.
// Bonfire: Factorialize a Number
// Author: @shahrzadmn
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function factorialize(num) {
var i = num;
var newNum = 1;
for (i; i > 1; i--){
newNum *= i;
}
return newNum;
}
factorialize(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment