Tuesday, 27 August 2013

Recursion counter inside a C++ function

Recursion counter inside a C++ function

Doing an assignment on recursive functions at the moment. Was asked to do
a Fibonacci program and did so with out much issue. But I'm need to make a
counter for it, and here is where I'm getting stuck.
I've got this function
int fibonacci(int n)
{
if( n == 0 )
{
//my fibonacci code
}
else if( n == 1 )
{
//my fibonacci code
}
else
{
//my fibonacci code
}
}
So how to I add a counter to this? Ever time I add a counter it returns
the wrong number.

No comments:

Post a Comment