2
public int numberOfMatches(int n) {3
// This is the problem's base case; we know that if n == 1,4
// the number of matches played must be 0, since the last team left5
// can't play a match against themselves.8
// We declare an int to hold our recursive solution.11
// We initialize res using a recursive call, reducing n12
// as described in the problem.14
res = numberOfMatches(n / 2);15
// After the recursive call is executed, we add the appropriate value to16
// our solution variable.19
res = numberOfMatches((n - 1) / 2 + 1);23
// Our initial call to numberOfMatches()24
// will return the total number of matches25
// added to res in each recursive call.