Combinatorics and Integer solution Based problem The number of ways in which we can choose $2$ distinct integers from $1$ to $100$ such that difference between them is at most $10$ is?
(I got the answer as 90+91+92+...+99 by analytical method)
can someone provide me a combinatorial method? 
 A: Here’s a much shorter and somewhat more combinatorial approach.
For each integer $n\in[1,90]$ there are $10$ pairs having $n$ as smaller member; that’s $900$ pairs. In addition, each of the $\binom{10}9=45$ pairs of integers in $\{91,\ldots,100\}$ must be counted, for a total of $945$ pairs.
A: As suggested by RolfSievers,   The number of ways in which we can choose 2 distinct integers from 1 to 100 such that difference between them is exactly:   $10 \to  90 ::: {(1,11),(2,12),...,(90,100)}$   $9 \to  91 :::{(1,9),(2,10),...,(91,100)}$   $8 \to  92 $   $7 \to  93 $   $6 \to  94 $   $5 \to  95 $   $4 \to  96 $   $3 \to  97 $   $2 \to  98 $   $1 \to  99 $   So, in the end we get a total of $945$.
A: Here is my solution written down anew, with less numbers and more combinatorics. This is most likely not the solution intended by the book, but it
just as valid.
We ask about the number of ways one can select two distinct numbers out of $1,\dots, n$ such that their distance is at most $a$.

To break this problem down into pieces, consider the number of ways to select two distinct numbers out of $1,\dots,n$ such that their distance is exacty $a$.

Assuming the lower number is $x$, the higher number is $x+a$. We are restricted by


*

*$1 \leq x$ as well as

*$x+a \leq n ⇔ x \leq n - a$.


As a consequence we collect $n-a$ tuples of the form $(1,a+1), \dots, (n-a, n)$.

We can understand the condition “the distance is at most a” as “the distance is in $\{1,\dots,a\}$” and sum accordingly.
$$\sum_{d=1}^{a} (n-d) = \sum_{d=1}^{a} n - \sum_{d=1}^{a} d = an - \frac{a(a-1)}{2}$$
Plugging in $n=100, a=10$ yields $1000 - 55 = 945$.
