//re-write this factorial function using a loop instead of recursion.
function fact(num) {
if (num === 1)
return 1;
else
return num * fact(--num);
}
console.log(`4! = ${fact(4)}`); //should be 24
//re-write this exponent function using recursion
//should return a^b - a to the power of b
function exp(a,b) {
let result = 1;
for (let i=0; i<b; i++) {
result *= a;
}
return result;
}
console.log(`2^8 = ${exp(2,8)}`) //should be 256