Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose $1\le x \le k, 1\le y \le k$, and we need to find a explicit formula for the the number of integers solution for the equation such that $$x+y=z$$ where $z \in\{2,...,2k\}$

I'm doing this because I am trying to find the probability mass function of the distribution $$Z=X+Y$$ where $X$ and $Y$ are two discrete uniform distribution random variables on $\{1,...,k\}$.

And while I was trying to find the pmf of $Z$, it occured to me that $$f_Z(z) = \dfrac{\text{ The number of solutions for the linear Diophantine equation above}}{k^2}$$

Am I overthinking this? Or am I approaching the problem in a wrong way?

share|cite|improve this question
By "$z =\{2,...,2k\}$", do you mean $z \in\{2,...,2k\}$? – joriki Nov 18 '11 at 20:17
@joriki Yes, it was a typo.Thanks for pointing it out – geraldgreen Nov 18 '11 at 20:20
up vote 2 down vote accepted

Note that $1 \leq x \leq z$.

Case 1: $2 \leq z \leq k+1$. Then any $1 \leq x \leq z-1 $ together with $ y= z-x$ works. Note that in this case $1 \leq y \leq k+1-1$, is in the right range.. In this case there are $z-1$ solutions.

Case 2: $k+1 < z$. Since $k+1< z =x+y \leq x+k$ we need $x >1$. Actually $z \leq x+k$ gives us the right lower bound:

$$x \geq z-k \,.$$

Now for each $z-k \leq x \leq k$ we can set $y=z-x$. $y $ is in the right range, since $z-k \leq x$ means $y \leq k$, while $x+1 \leq k+1 < z$ means $y \geq 1$.

In this case there are $k-(z-k)+1=2k-z+1$ solutions.

share|cite|improve this answer
You are right. I might have been overthinking this problem. – geraldgreen Nov 19 '11 at 23:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.