tp recursivite

This commit is contained in:
Simoes Lukas
2025-10-09 12:11:25 +02:00
parent 56258c01e6
commit 91d20e0ba6
15 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
public class Factorielle {
public static int factorielle(int n, int indentation) {
for (int i = 0; i != indentation; i++) {
System.out.print(" ");
}
System.out.println("Valeur de n : " + n);
if (n == 1) {
return 1;
}
for (int i = 0; i != indentation; i++) {
System.out.print(" ");
}
System.out.println("Valeur renvoyée : " + n + factorielle(n - 1, indentation++));
return n * factorielle(n - 1, indentation++);
}
}