How many different values $3a+8b$ can take if $0\leq a\leq 10$ and $0\leq b\leq 21$? How many different values can $pa+qb$ where $p$ and $q$ are coprime to each other, and $a$ and $b$ are whole numbers can take given $0 \le a \le m$ and $0 \le b \le n$. 
How to approach this question in general, and what if three variables are given. 
EDIT: The solution provided now looks wrong to me, as I tried the same logic for 0<=a<=47 and 0<=b<=17, and number of repetitions came out to be more than the number of cases.
 A: We discuss only the numerical example of the title. There are $(11)(22)$ possibilities for the ordered pair $(a,b)$. We need to get a handle on the number of "repeats."  Suppose that $3a+8b=3a'+8b'$, where $a,a'$ are in the specified range, as are $b$ and $b'$. Without loss of generality we may assume that $a\gt a'$.
Then $3(a-a')=8(b'-b)$. Since $3$ and $8$ are relatively prime, $a-a'$ must be divisible by $8$. Because $a$ and $a'$ are restricted to the range $0$ to $10$, we have $3$ possibilities: (i) $a=8$, $a'=0$: (ii) $a=9$, $a'=1$; $a=10$, $a'=2$. 
Let us look for example at Case (i), $a=8$, $a'=0$. So we are counting the number of pairs $b,b'$ such that $24+8b=8b'$, that is, $b'-b=3$. Here $b$ can take any value from $0$ to $18$. That gives $19$ repetitions. 
Count similarly what happens in Cases (ii) and (iii). The arithmetic is the same.
For another concrete two variable case, a similar approach will work.  But the idea breaks down for more variables, since getting hold of the number of "repeats" becomes too complicated.
