From 0f1bd24a0c59d7c9720f59cc4f414feb431226dd Mon Sep 17 00:00:00 2001
From: BARRE Milo <milo.barre9@etu.univ-lorraine.fr>
Date: Fri, 28 Mar 2025 20:31:07 +0100
Subject: [PATCH] Exercice 8

---
 compte-rendu.txt | 11 ++++++++++-
 ex8.ts           | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 ex8.ts

diff --git a/compte-rendu.txt b/compte-rendu.txt
index 8c28cf1..c0f9df3 100644
--- a/compte-rendu.txt
+++ b/compte-rendu.txt
@@ -58,4 +58,13 @@ Exercice 7 :
     return x * y; // Solution optimale
 }
 
-    6. Programme : voir ex7.ts
\ No newline at end of file
+    6. Programme : voir ex7.ts
+
+Exercice 8 : 
+
+
+fonction multiplication modifiée :
+
+  function multiplication(x: number, y: number): number {
+    return x * y;
+}
\ No newline at end of file
diff --git a/ex8.ts b/ex8.ts
new file mode 100644
index 0000000..ad707b0
--- /dev/null
+++ b/ex8.ts
@@ -0,0 +1,34 @@
+let n=5;
+console.log(deb8(n));
+function deb8(n:number):number{
+    if (n===0){
+        return 1
+    }
+
+    let valeur = n * deb8(n-1);
+    return valeur;
+}
+
+
+
+    const testCases = [
+        [0, 0], [5, 3], [3, 5], [-5, -2], [-2, -5],
+        [-74, 2], [-1, 75], [10, -25], [10, -3]
+    ];
+
+    testCases.forEach(([x, y]) => {
+        console.log(`multiplication(${x}, ${y}) = ${multiplication(x, y)}`);
+    });
+
+
+function factorial(n: number): number {
+    if (n < 0) throw new Error("n must be >= 0");
+    let result = 1;
+    for (let i = 2; i <= n; i++) result *= i;
+    return result;
+}
+
+function multiplication(x: number, y: number): number {
+    return x * y;
+}
+
-- 
GitLab