General formula for Code

Newbie Member
17Nov2010,02:19   #1
eblack10's Avatar
C code
Code:
int f(int n)
{
return(0);
if(n==1)
return(1);
printf("ADD");
return(f(n-1)+f(n-2));
}
What general formula can you derive from this if someone was to use f(n)?
Go4Expert Member
17Nov2010,03:30   #2
ihatec's Avatar
Sorry but your code will stop execution at first line, but I suppose you want to obtain recursive algorithm for n-th Fibbonacci number.
eblack10 like this
Newbie Member
17Nov2010,20:56   #3
eblack10's Avatar
That is what I thought. I was argued down that it should compile. Thanks!
Ambitious contributor
19Nov2010,01:18   #4
jimblumberg's Avatar
Quote:
Originally Posted by eblack10 View Post
That is what I thought. I was argued down that it should compile. Thanks!
It will compile, but should have a warning about unreachable code.

Jim