/*
The Nth Fibonacci number is defined as the sum of the (N-1)th Fibonacci
number plus the (N-2)th Fibonacci number. The exception is that if N is
less than or equal to 2, the Nth Fibonacci number is defined to be 1.
*/
public class Fibonacci extends java.applet.Applet {
public long N;
private long fib(long n) {
if (n <= 2)
return 1;
else
return fib(n - 1) + fib(n - 2);
}
public void Fibonacci (long n) {
N = fib(n);
}
} |