Skip to content

Instantly share code, notes, and snippets.

@AntonisFK
Last active April 6, 2016 22:19
Show Gist options
  • Save AntonisFK/7d31d623e0c4b3895458f5cd9daec93f to your computer and use it in GitHub Desktop.
Save AntonisFK/7d31d623e0c4b3895458f5cd9daec93f to your computer and use it in GitHub Desktop.
//factorial(3) = 3*2*1
var factorial = function(num){
var factor =1;
if(num > 0){
for(var i=1; i<=num; i++){
factor *= i;
}
return factor;
}
};
factorial(9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment