Click here to Skip to main content
15,894,405 members
Articles / Programming Languages / C++

Fibonacci Recursive and Non Recursive C++

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
14 Sep 2010CPOL 5.5K   2  
A stupid change :) int FibonacciR::Fibonacci(const int &n){ if(n<=1) return n; return Fibonacci(n-1) + Fibonacci(n-2); } :laugh:

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
20 Sep 2010Aescleal
If you can, the quickest way to calculate the Fibonacci numbers is to do it at compile time. This is a case of "My recursive method is quicker than yours...":templateclass fibonacci_number{ public: static const T value = fibonacci_number<T, n -...
Please Sign up or sign in to vote.
18 Sep 2010joseph.arul83@gmail.com 2 alternatives  
Non Recursive and Recursive implementation of Fibonaci series in C++. Emphasis is on the complexity involved in the different implementations.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Afghanistan Afghanistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions