Search This Blog

Thursday, March 25, 2010

//Fibonacci Recursive Way:

class RecFibo
{
void series(int term)
{
for(int i=1; i<=term;i++)
{
System.out.println(fibo(i));
}
}
double fibo(int n)
{
if(n<=2.0)
return 1.0;
else
return fibo(n-1)+fibo(n-2);
}
}

//If you don't want very long series, you may change double to int and put the '.0' off from the rear side of the numbers.


Discussing Java application programming across the barrier of classroom for the young minds.

1 comment:

  1. Thanks a lot sir....well sir...now need your wishes heavily for tomorrow's exam...although I'm having a bit more confidence than the ARTS subject exams.....:)

    ReplyDelete