update
This commit is contained in:
15
DEV.3.2/TP/TP2-Recursivite/Fibonacci.java
Normal file
15
DEV.3.2/TP/TP2-Recursivite/Fibonacci.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
public class Fibonacci {
|
||||||
|
public Fibonacci() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int form(int val) {
|
||||||
|
if(val == 0) {
|
||||||
|
return 0;
|
||||||
|
} else if(val == 1) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return form(val -1) + form(val -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
DEV.3.2/TP/TP2-Recursivite/ex1-Appels/Appels.class
Normal file
BIN
DEV.3.2/TP/TP2-Recursivite/ex1-Appels/Appels.class
Normal file
Binary file not shown.
23
DEV.3.2/TP/TP2-Recursivite/ex1-Appels/Appels.java
Normal file
23
DEV.3.2/TP/TP2-Recursivite/ex1-Appels/Appels.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
public class Appels {
|
||||||
|
|
||||||
|
public Appels(int val) {
|
||||||
|
int indentation = 0;
|
||||||
|
fact(val, indentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int fact(int nb, int indentation) {
|
||||||
|
if(nb > 0) {
|
||||||
|
System.out.println(" ");
|
||||||
|
return nb*fact(nb-1,indentation++);
|
||||||
|
} else {
|
||||||
|
Thread.dumpStack();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
System.out.println(nb+"! = "+fact(nb, indentation));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new Appels(Integer.parseInt(args[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
5
DEV.3.2/TP/TP2-Recursivite/ex2-Tableaux/Tableaux.java
Normal file
5
DEV.3.2/TP/TP2-Recursivite/ex2-Tableaux/Tableaux.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
public class Tableaux {
|
||||||
|
public Tableaux() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user