Sunday, August 2, 2009

Fibonacci sequence in c++...can anyone help me??

i need it written in c++ language...i tried to do it...but it stops at 2. PLS HELP

Fibonacci sequence in c++...can anyone help me??
search online, google search, .... that's what i did and i came cross the source codes for it except it was using iostream library
Reply:Post your code so we can help you.





If you're writing it recursively, which is in fact the easiest way to write fibonacci code, you need to have the following parts:





base cases:


if n==1, return 1


if n==2, return 1


otherwise: return fibonacci(n-1) + fibonacci(n-2)


No comments:

Post a Comment