17 lines
333 B
Java
17 lines
333 B
Java
|
public class Fib {
|
||
|
public static long fib(long n) {
|
||
|
if (n == 0) return 0;
|
||
|
if (n == 1) return 1;
|
||
|
return fib(n-1) + fib(n-2);
|
||
|
}
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
long a = 0;
|
||
|
long r = 0;
|
||
|
|
||
|
a = Long.parseUnsignedLong(args[0]);
|
||
|
r = fib(a);
|
||
|
System.out.println("fib("+ Long.toUnsignedString(a) + ") = " + r);
|
||
|
}
|
||
|
}
|