Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

C++ help [04 Nov 2006|12:49am]
Hey I'am wondering what every one gets for this peice of code.


Can you tell what the following function computes? For example, what is the result of calling mystery(10) ?



int mystery(int x)
{
if (x == 0)
return 0;
else
return x + mystery(x-1);



Now even without coding it. I beileve when calling mystery it will pass 10 down to the function. Its not equal to 0 so it goes to the next code. the results would be 19??


tbnak you in advance.
8 comments|post comment

navigation
[ viewing | November 4th, 2006 ]
[ go | previous day|next day ]
Image