# Proportion of all evenly-distanced pairs of numbers in a number line?

Let's say I have a number line of integers from 1 to 5 (5 total numbers). There are 4 pairs of evenly-distanced numbers: $$(1, 3), (2, 4), (3, 5), (1, 5)$$. Furthermore, there are $${5 \choose 2} = 10$$ possible pairs of numbers. So we observe the proportion of evenly-distanced numbers is $$\frac{4}{10}$$.

In general, given a number from 1 to $$n$$ (where $$n > 1$$), what is the proportion of evenly-distanced pairs? Other comments:

• We can't pair a number with itself. So $$(1, 1)$$ doesn't count.
• Order doesn't change a pair. So $$(1, 5)$$ is not a different pair from $$(5, 1)$$.

I know there are $${n \choose 2}$$ possible pairs, but I am having a tough time figuring out how to count the number of evenly-distanced pairs for a general $$n$$.

• Notice your example interval has $3$ odd numbers and $2$ even numbers, and the total number of evenly-distanced pairs is $4=3+1=\binom32+\binom22$ ... can you generalize? Mar 10, 2022 at 8:14

Firstly I apologize for my inexperience because I'm new here, I hope I will provide an appropriate answer for you.

Let $$n$$ be a whole number. Then there are two cases.

Case 1 ($$n$$ is even). If $$n$$ is an even whole number, then $$n=2k$$ for some whole number $$k$$. So there are only these pairs of evenly-distanced numbers:

$$(1,3), (2,4), ..., (2k-3,2k-1), (2k-2,2k)$$ [$$2k-2$$ pairs with $$2$$-distanced] $$(1,5), (2,6), ..., (2k-5,2k-1), (2k-4,2k)$$ [$$2k-4$$ pairs with $$4$$-distanced] $$(1,7), (2,8), ..., (2k-7,2k-1), (2k-6,2k)$$ [$$2k-6$$ pairs with $$6$$-distanced]

$$\vdots$$

$$(1,2k-3), (2,2k-2), (3,2k-1), (4,2k)$$ [$$4$$ pairs with $$(2k-4)$$-distanced] $$(1,2k-1), (2,2k)$$ [$$2$$ pairs with $$(2k-2)$$-distanced]

Here it follows that the number we are looking for is the sum of even integers from $$2$$ to $$2k-2$$, i.e. $$2 + 4 + ... + (2k-4) + (2k-2) = k^2-k$$.

Now we come to the other case.

Case 2 ($$n$$ is odd). If $$n$$ is an odd whole number, then $$n = 2k+1$$ for some whole number $$k$$. So there are only these pairs of evenly-distanced numbers:

$$(1,3), (2,4), ..., (2k-2,2k), (2k-1,2k+1)$$ [$$2k-1$$ pairs with $$2$$-distanced] $$(1,5), (2,6), ..., (2k-4,2k), (2k-3,2k+1)$$ [$$2k-3$$ pairs with $$4$$-distanced] $$(1,7), (2,8), ..., (2k-6,2k), (2k-5,2k+1)$$ [$$2k-5$$ pairs with $$6$$-distanced]

$$\vdots$$

$$(1,2k-3), (2,2k-2), (3,2k-1), (4,2k), (5,2k+1)$$ [$$5$$ pairs with $$(2k-4)$$-distanced] $$(1,2k-1), (2,2k), (3,2k+1)$$ [$$3$$ pairs with $$(2k-2)$$-distanced] $$(1,2k+1)$$ [$$1$$ pair with $$2k$$-distanced]

Here it follows that the number we are looking for is the sum of odd integers from $$1$$ to $$2k-1$$, i.e. $$1 + 3 + ... + (2k-3) + (2k-1) = k^2$$.

Finally, the answer is $$(n/2)^2-(n/2)$$ when $$n$$ is even, and $$((n-1)/2)^2$$ when $$n$$ is odd.

I hope you will be pleased with the answer, good luck with the rest of your life!