CS2613/labs/L10/rec-arith.js

16 lines
226 B
JavaScript
Raw Normal View History

2022-10-17 10:24:22 -03:00
function plus(a,b) {
if (a === 0) {
return b;
} else {
return plus(a-1, b+1);
}
}
function mult(a,b) {
if (a === 0) {
return 0;
} else {
return plus(mult(a-1, b), b);
}
}
exports.plus = plus;
exports.mult = mult;