why does this program go so slow?
Code:#include<iostream.h> int fib(int n){ if(n==1 || n==2) return 1; return fib(n-1)+fib(n-2); }; void main(){ for(int i=1; i<70; i++) cout<<" fib("<<i<<") = "<<fib(i)<<endl; }
| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | VB Forums | Developer.com |
|
Results 1 to 5 of 5
Thread: Recursive programThreaded View
|
Click Here to Expand Forum to Full Width |