class Fibonacci {
public static long fibonacci(int n) {
return n < 2 ? n : fibonacci(n - 2) + fibonacci(n - 1);
}
public static void main
(String[] args
) { for (int i = 0; i <= 10; i++) {
System.
out.
println("Fibonacci(" + i
+ ") = " + fibonacci
(i
)); }
}
}
Y2xhc3MgRmlib25hY2NpIHsKICAgIHB1YmxpYyBzdGF0aWMgbG9uZyBmaWJvbmFjY2koaW50IG4pIHsKICAgICAgICByZXR1cm4gbiA8IDIgPyBuIDogZmlib25hY2NpKG4gLSAyKSArIGZpYm9uYWNjaShuIC0gMSk7CiAgICB9CiAgICAKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8PSAxMDsgaSsrKSB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRmlib25hY2NpKCIgKyBpICsgIikgPSAiICsgZmlib25hY2NpKGkpKTsKICAgICAgICB9CiAgICB9Cn0=