From 1c0b7e612de31228f5cc196d3030188fbf531ecd Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Wed, 5 Oct 2022 10:08:15 -0300 Subject: [PATCH] Create loop-arith.js --- labs/L08/loop-arith.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 labs/L08/loop-arith.js diff --git a/labs/L08/loop-arith.js b/labs/L08/loop-arith.js new file mode 100644 index 0000000..294759d --- /dev/null +++ b/labs/L08/loop-arith.js @@ -0,0 +1,17 @@ +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; +} + +exports.plus = plus; +exports.mult = mult; \ No newline at end of file