Skip to content
Snippets Groups Projects
Commit 0ee98654 authored by MALLINGER Robin's avatar MALLINGER Robin
Browse files

refresh

parent 26fc8ab4
No related branches found
No related tags found
No related merge requests found
function multiply(x: number, y: number): number {
if (y < 0) {
x = -x;
y = -y;
}
let result = 0;
for (let i = 0; i < y; i++) {
result += x;
}
return result;
}
function testMultiply() {
const testCases = [
[0, 0], [5, 3], [3, 5], [-5, -2], [-2, -5],
[-74, 2], [-1, 75], [10, -25], [10, -3]
];
for (const [x, y] of testCases) {
console.log(`multiply(${x}, ${y}) = ${multiply(x, y)}`);
}
}
testMultiply();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment