Click here to Skip to main content
15,881,600 members
Articles / Programming Languages / C++
Alternative
Tip/Trick

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.4K   2  
A stupid change :) int FibonacciR::Fibonacci(const int &n){ if(n<=1) return n; return Fibonacci(n-1) + Fibonacci(n-2); } :laugh:
A stupid change :)
int FibonacciR::Fibonacci(const int &n){
if(n<=1)
    return n;
return Fibonacci(n-1) + Fibonacci(n-2);
}

:laugh:

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

 
-- There are no messages in this forum --