# Choosing pairs of numbers with a sum-bound

• Jan 25th 2010, 04:45 AM
shinkansen
Choosing pairs of numbers with a sum-bound
Dear Forum,

I have the following question:

How can one write up a closed formula for computing the number of possible pairs of numbers in a set, whose sum is lees than or equal to a constraint?

For example: if we have the numbers from 1 to 100 what is the number of cases when the sum of the two numbers in a pair is less than 10. Here, the 1, 100 and 10 values are not important at all, I just wanted make it easier to demonstrate the problem. Of course, I would need a so called closed formula for that, I am not sure whether it exists. (Iterative solution is unfortunately not an option).

Any help would be appreciated!

Let's denote what you called a "constraint" as $\displaystyle n$. Now, you can only make pairs of numbers $\displaystyle a_1$ and $\displaystyle a_2$, such that $\displaystyle a_1+a_2<n$, when $\displaystyle a_1,a_2\in [1,n-2]$. Therefore, there are $\displaystyle n-2$ pairs you can make with $\displaystyle 1$, $\displaystyle n-3$ pairs with $\displaystyle 2$, $\displaystyle n-4$ pairs with $\displaystyle 3$, ... , and $\displaystyle 1$ pair with the $\displaystyle (n-2)$ number: $\displaystyle (n-2)+(n-3)+...+2+1=\frac{(n-2)(n-1)}{2}$ is the numbers of pairs you seek. (Wink)