12 Octobre
This commit is contained in:
30
DEV3.2/TP2/Appels.java
Normal file
30
DEV3.2/TP2/Appels.java
Normal file
@@ -0,0 +1,30 @@
|
||||
public class Appels {
|
||||
|
||||
public static int indentation;
|
||||
|
||||
public static long fact(long n){
|
||||
for (int i = 0; i < indentation; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println("Argument début: "+n);
|
||||
indentation++;
|
||||
if(n==1l){
|
||||
//Thread.dumpStack();
|
||||
return 1;
|
||||
}else{
|
||||
long r=n*fact(n-1l);
|
||||
for (int i = 0; i < indentation-1; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
indentation--;
|
||||
System.out.println("Argument fin: "+r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]){
|
||||
long x=Long.parseLong(args[0]);
|
||||
indentation=0;
|
||||
System.out.println(x+"! = "+fact(x));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user