factorialize a number (recursion)
Recursion is the method of calling a function inside of itself in order to perform a given action. In this example, we are factorializing a given number (multiplying the number by every number less than itself but greater than one). Recursion works here by simplifying the function which could be slightly longer by using a for loop).
function factorialize(num) {
if(num === 0) { return 1;}
return num * factorialize(num - 1);
}
factorialize(5);
For loop (alt):
function factorialize(num) {
for (a = 1;num >= 1; num--) {
a = num * a;
}
return a;
}
factorialize(5);










