Recurrences & Generating Functions


Answer & solution
Answer: C(n+m,n) = C(n+m,m). (no official key was published)
The boundary values are F(0,m)=F(n,0)=1. Compare them with G(n,m)=C(n+m,n): G(0,m)=C(m,0)=1 and G(n,0)=C(n,n)=1, so the axes agree.
For n,m≥1, Pascal's identity gives
G(n−1,m)+G(n,m−1)
=C(n+m−1,n−1)+C(n+m−1,n)
=C(n+m,n)=G(n,m).
Thus G obeys exactly the same recurrence and boundaries as F. Induction on n+m proves equality: each interior value depends only on two smaller sums, so once their equality is established the new value also agrees. Therefore F(n,m)=C(n+m,n)=C(n+m,m).
A useful combinatorial interpretation is the number of lattice paths from (0,0) to (n,m) using n horizontal and m vertical moves. Select which n of the n+m positions are horizontal. On either axis there is only one path, and every interior path arrives from one of its two preceding grid points, explaining both the boundary and recurrence.
The answer is symmetric in n and m, as the function definition requires. At m=2 it specializes to (n+1)(n+2)/2. This formula is the returned value, not the number of function activations; the directly recursive implementation recomputes many identical arguments, which the next subpart counts separately.