function paw(res, num) {
if (num === 1) {
return res;
} else {
return res * paw(res, num - 1);
}
}
var result = paw(2, 5);
console.log(result);
paw(2, 5) = 2 * paw(2, 4)
2 * paw(2, 4) --> paw(2, 4) = 2 * paw(2, 3)
2 * (2 * paw(2, 3)) --> paw(2, 3) = 2 * paw(2, 2)
2 * (2 * (2 * paw(2, 2))) --> paw(2, 2) = 2 * paw(2, 1)
2 * (2 * (2 * (2 * paw(2, 1)))) --> paw(2 ,1) = 2
2 * (2 * (2 * (2 * 2)))