General formula for Code

eblack10's Avatar, Join Date: Nov 2010
Newbie Member
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)?
ihatec's Avatar, Join Date: Sep 2010
Go4Expert Member
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
eblack10's Avatar, Join Date: Nov 2010
Newbie Member
That is what I thought. I was argued down that it should compile. Thanks!
jimblumberg's Avatar
Ambitious contributor
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