Used a while loop for this and it worked ok.
function factorialize(num) {
factorial = 1;
i = 1;
while(i<=num)
{
factorial = factorial * i;
i++;
}
return factorial;
}
factorialize(5);
No comments:
Post a Comment