CS2613/labs/L09/loop-arith.js
2022-10-12 11:10:43 -03:00

25 lines
344 B
JavaScript

function plus(a,b) {
for (let i=0; i < a; i++){
b++;
}
return b;
}
function mult(a,b) {
sum=0;
for(let i=0; i < a; i++) {
sum = plus(sum, b)
}
return sum;
}
function minus(a,b) {
for (let i=0; i < b; i++){
a--;
}
return a;
}
exports.plus = plus;
exports.mult = mult;
exports.minus = minus;