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));
}
}

Comments

Popular posts from this blog

GL_QUAD_STRIP Example In OpenGl

GL_POLYGON Example In OpenGl