Recursive function

The following recursive function has a return value of type unsigned int and two
parameters of the same type.
unsigned int f1(unsigned int a, unsigned int b)
{
if (a == 0)
return b;
else if (b == 0)
return a;
else return f1(a, b-1) + b;
}

1.What is the return value of f1 called with values 3 for parameter a and 6 for parameter
b?
2.What mathematical function is calculated by f1?
Great homework questions.
What is the return value of f1 with values 3 for parameter a and 6 for parameter b?

If the function works, it should be 24.

What mathematical function is calculated by f1?

The sigma notation.
Topic archived. No new replies allowed.