Probability interview question Suppose we have three positive integers $A, B, C$. We randomly choose an integer $a$ in the range $[0,A]$ and an integer $b$ in the range $[0,B]$. Find the probability that $a + b\leq C$.
I am unable to proceed in this question. Any hints .

Let $S_C$ be the number of couples $(a,b)$, $a\in [0,A]$ and $b\in [0,B]$ such that $a+b \leq C$. It is clear that $S_0=1$ because the only couple that can sum up to zero is $(0,0)$. Moreover if $C>A+B$ then $S_C=S_{A+B}$ since all couples that are counted in $S_C$ were already counted in $S_{A+B}$. Without loss in generality we can assume that $A\leq B$. Let us study the function $T_C=S_{C+1}-S_C$. It corresponds to the number of couples $a,b$ where $a+b=C$. This is easier to count , e.g. if A and B are big enough then for $T_3$ we count the couples $(3,0), (2,1), (1,2)$ and $(0,3)$. In fact we can conclude easily then for $C$ small enough we have $T_C=C+1$. But this only works if $C \leq A$. Once $C>A$ we must start off with $(A,C-A),(A-1,C-A+1),\ldots,(0,C)$ (on the condition that $B$ is big enough so that $C-A \in [0,B]$). In this case we will have $T_C=A+1$. But this can not continue forever since in case $C>B$ we will not even arrive to $(0,C)$ but only to $(C-B,B)$. We conclude that for $C>B$ we have $T_C=A+B-C+1$ so globally we have :$$T_C =
\begin{cases}
C+1,  & \text{for $C \leq A$} \\
A+1,  & \text{for $A \leq C \leq B$}\\
A+B-C+1,  & \text{for $B \leq C \leq A+B+1 $}\\
0,  & \text{for $A+B+1 \leq C $}\\
\end{cases} $$
To reconstruct $S$ all we have to do is to "integrate" this function over the different domains. A bit of calculation gives: 
 $$S_C =
\begin{cases}
C(C+1)/2,  & \text{for $C \leq A$} \\
A(A+1)/2+(A+1)(C-A),  & \text{for $A \leq C \leq B$}\\
f(C),  & \text{for $B \leq C \leq A+B+1 $}\\
(A+1)(B+1)  & \text{for $A+B+1 \leq C $}\\
\end{cases} $$
Where $f(C)=(A+1)(B+1)-(A+B+1-C)(A+B+1-C+1)/2$.
