Recursion functions

1
2
3
4
5
6
7
int m3(int n)
{
	if (n==1)
		return 25;
	else 
		return n + m3(n-1);
}


If I called cout << m3(5); in int main would it really return 39? Why is that?
Last edited on
If I called cout << m3(5); in int main would it really return 39?

Yes.

Why is that?

Trace through the logic.
Topic archived. No new replies allowed.