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

mise a jour a cause d'erreur

parent 95543405
No related branches found
No related tags found
No related merge requests found
function factorial(n: number): number {
if (n < 0) {
throw new Error("Le factoriel n'est défini que pour les entiers non négatifs.");
}
let result = 1;
for (let i = 2; i <= n; i++) {
result *= i;
}
return result;
}
let n = 5;
console.log(factorial(n)); // Affiche 120
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