From 43d8fac2f00768deb71c7731a50cc2a86b711813 Mon Sep 17 00:00:00 2001
From: CORONA Nikola <git config --local user.email>
Date: Fri, 4 Apr 2025 14:46:43 +0200
Subject: [PATCH] TD5 Exercice 2

---
 TD5 Test/Exercice.test.ts |  3 +++
 TD5 Test/MesMaths.ts      | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/TD5 Test/Exercice.test.ts b/TD5 Test/Exercice.test.ts
index 7a49112..d582e91 100644
--- a/TD5 Test/Exercice.test.ts	
+++ b/TD5 Test/Exercice.test.ts	
@@ -11,3 +11,6 @@ Deno.test("multiplication par 0", () => {
 Deno.test("multiplication par un nombre négatif", () => {
  assertEquals(multAdd(3, -8), -24);
 });
+Deno.test("multiplication par 2 nombre négatif", () => {
+    assertEquals(multAdd(-8, -8), 64);
+   });
diff --git a/TD5 Test/MesMaths.ts b/TD5 Test/MesMaths.ts
index b29286f..fccd148 100644
--- a/TD5 Test/MesMaths.ts	
+++ b/TD5 Test/MesMaths.ts	
@@ -1,7 +1,15 @@
 export function multAdd(x: number, y: number): number {
     let resultat = 0;
+    let inf = 0;
+    if (y < 0){
+        y = -y
+        inf = 1 ;
+    }
     for (let i = 0; i < y; i++) {
     resultat += x;
     }
-    return resultat;
-   }
\ No newline at end of file
+
+    if (inf === 1 ) return -resultat ;
+    else return resultat;
+   }
+
-- 
GitLab