---
title: "Bounded Integer Solutions to x1 + x2 + x3 + x4 = 24"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-stars-bars-bounded-complementary"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-11-26T15:30:00+05:30"
---

# Bounded Integer Solutions to x1 + x2 + x3 + x4 = 24

Find the number of non-negative integer quadruples $(x_1, x_2, x_3, x_4)$ satisfying
$$x_1 + x_2 + x_3 + x_4 = 24$$
subject to the upper bounds $x_1 \le 7$, $x_2 \le 8$, $x_3 \le 9$, and $x_4 \le 10$.

## Textbook Solution

We apply the Principle of Inclusion-Exclusion together with Stars and Bars.
Let $U$ be all non-negative integer solutions to $x_1 + x_2 + x_3 + x_4 = 24$:
$$|U| = \binom{24 + 4 - 1}{3} = \binom{27}{3} = \frac{27 \times 26 \times 25}{6} = 2925.$$
Define the bad events $A_1: x_1 \ge 8$, $A_2: x_2 \ge 9$, $A_3: x_3 \ge 10$, and $A_4: x_4 \ge 11$.

1. **Single violations**:
   - $|A_1| = \binom{24 - 8 + 3}{3} = \binom{19}{3} = 969$
   - $|A_2| = \binom{24 - 9 + 3}{3} = \binom{18}{3} = 816$
   - $|A_3| = \binom{24 - 10 + 3}{3} = \binom{17}{3} = 680$
   - $|A_4| = \binom{24 - 11 + 3}{3} = \binom{16}{3} = 560$
   Sum $= 969 + 816 + 680 + 560 = 3025$.

2. **Double violations**:
   - $|A_1 \cap A_2| = \binom{24 - 17 + 3}{3} = \binom{10}{3} = 120$
   - $|A_1 \cap A_3| = \binom{24 - 18 + 3}{3} = \binom{9}{3} = 84$
   - $|A_1 \cap A_4| = \binom{24 - 19 + 3}{3} = \binom{8}{3} = 56$
   - $|A_2 \cap A_3| = \binom{24 - 19 + 3}{3} = \binom{8}{3} = 56$
   - $|A_2 \cap A_4| = \binom{24 - 20 + 3}{3} = \binom{7}{3} = 35$
   - $|A_3 \cap A_4| = \binom{24 - 21 + 3}{3} = \binom{6}{3} = 20$
   Sum $= 120 + 84 + 56 + 56 + 35 + 20 = 371$.

3. **Triple or quadruple violations**: The minimum sum for any three bad events is $8 + 9 + 10 = 27 > 24$, so all triple and quadruple intersections are empty.

By Inclusion-Exclusion:
$$\text{Valid solutions} = 2925 - 3025 + 371 = 271.$$

## Vedic Shortcut

Use the **Complementary Deficit Substitution**!
Notice the maximum possible sum is $7 + 8 + 9 + 10 = 34$, which is close to $24$. Define the deficits:
$$y_1 = 7 - x_1, \quad y_2 = 8 - x_2, \quad y_3 = 9 - x_3, \quad y_4 = 10 - x_4.$$
Then $y_1, y_2, y_3, y_4 \ge 0$ and
$$y_1 + y_2 + y_3 + y_4 = 34 - 24 = 10,$$
with $y_1 \le 7, y_2 \le 8, y_3 \le 9, y_4 \le 10$.
Now the total unrestricted solutions is just $\binom{10 + 3}{3} = \binom{13}{3} = 286$!
And no two upper bounds on $y_i$ can be violated simultaneously (since $8 + 9 = 17 > 10$):
- $y_1 \ge 8$: $\binom{10-8+3}{3} = \binom{5}{3} = 10$
- $y_2 \ge 9$: $\binom{10-9+3}{3} = \binom{4}{3} = 4$
- $y_3 \ge 10$: $\binom{10-10+3}{3} = \binom{3}{3} = 1$
- $y_4 \ge 11$: $0$

Answer $= 286 - (10 + 4 + 1) =$ **$271$** in 20 seconds!

## Common Mistakes

- **Using $x_i \ge 7$ instead of $x_i \ge 8$ for the bad event**: The complement of $x_1 \le 7$ in integers is $x_1 \ge 8$, not $x_1 \ge 7$.
- **Forgetting to check double intersections**: Stopping after single violations gives $2925 - 3025 = -100$, an obvious red flag.