Let $X$ and $Y$ be independent, each uniformly distributed on $\{1, 2, ..., n\}$. Find $P(X + Y = k)$ for $2 \le k \le 2n$.
\begin{align}P(X + Y = k) &= \sum_{(x,y)\,:\,x+y=k} P(x, y) \\ &= \sum_{(x,y)\,:\,x+y=k} \frac{1}{n^2} \\ &= (k - 1)\frac{1}{n^2} \\ &= \frac{k-1}{n^2} \end{align}
When $k = 2: (1, 1)$
When $k = 3: (1, 2), (2, 1)$
When $k = 4: (1, 3), (3, 1), (2, 2)$
When $k = 5: (1, 4), (4, 1), (2, 3), (3, 2)$
$$\#(x, y) = k - 1$$
Textbook Answer:
$\frac{k-1}{n^2}\,\,\,$ for $\,\,\,2 \le k \le n+1$
$\frac{2n-k+1}{n^2}\,\,\,$ for $\,\,\,n+2 \le k \le 2n$
Why are there $2$ intervals being considered?
Hint: Look what happens if you go "backwards" from $k=2n$ "down":
etc. What you've got will keep growing with growing $k$, but at some point the number of ways to get the sum $k$ starts shrinking. Thereby the second formula.