APL/DEV 3.2/TP02/Fibonnaci/Fibbonaci.java

17 lines
392 B
Java
Raw Normal View History

2022-10-07 11:13:46 +02:00
public class Fibbonaci {
public static int fibbo(int n, int r) {
switch (n) {
case 0:
return 0;
case 1:
return 1;
default:
return fibbo(n-2, r) + fibbo(n-1, r);
}
}
2022-10-12 13:29:36 +02:00
2022-10-07 11:13:46 +02:00
public static void main(String[] args) {
2022-10-12 13:29:36 +02:00
System.out.println(fibbo(Integer.parseInt(args[0]), 0));
2022-10-07 11:13:46 +02:00
}
}