Saturday, April 12, 2014

Fibonacci program in Java


public class fibnocci
{
static int fib(int n)
{
if((n==1)|| (n==2))
return 1;
else
return fib(n-1)+fib(n-2);
}
public static void main(String [] args)
{
System.out.println("fibnocci(7)= "+ fib(7));
}
}