// a recursive version of a function to find a factorial of a number
// a factorial of a number being the product of that number multiplied by all numbers between itself and 1 (e.g. 3! = 3 * 2 * 1. 4! = 4 * 3 * 2 * 1.)
function fac_rec(x){
if(x <= 1) return 1;
else return x * fac_rec(x-1);
}
No comments:
Post a Comment