---
title: "Coefficient of x^18 in (x + x^2 + ... + x^6)^5 via Stars & Bars"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-stars-bars-polynomial-coeff-x18"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-12-01T10:30:00+05:30"
---

# Coefficient of x^18 in (x + x^2 + ... + x^6)^5 via Stars & Bars

Find the coefficient of $x^{18}$ in the expansion of
$$\left(x + x^2 + x^3 + x^4 + x^5 + x^6\right)^5.$$

## Textbook Solution

Factor out $x^5$ from the polynomial:
$$\left(x + x^2 + x^3 + x^4 + x^5 + x^6\right)^5 = x^5 \left(1 + x + x^2 + x^3 + x^4 + x^5\right)^5.$$
Thus, we need the coefficient of $x^{18 - 5} = x^{13}$ in $\left(1 + x + \dots + x^5\right)^5$.
Write the geometric series as:
$$\left(\frac{1 - x^6}{1 - x}\right)^5 = (1 - x^6)^5 (1 - x)^{-5}.$$
Expand both factors:
$$(1 - x^6)^5 = 1 - \binom{5}{1}x^6 + \binom{5}{2}x^{12} - \dots = 1 - 5x^6 + 10x^{12} - \dots,$$
$$(1 - x)^{-5} = \sum_{n=0}^{\infty} \binom{n + 4}{4} x^n.$$
Collect the coefficient of $x^{13}$ from the product:
$$[x^{13}] = 1 \cdot \binom{13 + 4}{4} - 5 \cdot \binom{7 + 4}{4} + 10 \cdot \binom{1 + 4}{4}$$
$$= \binom{17}{4} - 5\binom{11}{4} + 10\binom{5}{4}.$$
Compute each binomial coefficient:
- $\binom{17}{4} = \frac{17 \times 16 \times 15 \times 14}{24} = 17 \times 10 \times 14 = 2380$,
- $\binom{11}{4} = \frac{11 \times 10 \times 9 \times 8}{24} = 11 \times 30 = 330$,
- $\binom{5}{4} = 5$.

Therefore:
$$[x^{13}] = 2380 - 5(330) + 10(5) = 2380 - 1650 + 50 = 780.$$

## Vedic Shortcut

Interpret $[x^{18}](x + \dots + x^6)^5$ combinatorially as **the number of ways $5$ standard dice can sum to $18$**, and use the **Symmetry Check**:
- By subtracting $1$ from each die, $b_1 + \dots + b_5 = 13$ with $0 \le b_i \le 5$.
- Note that the symmetric complement $c_i = 5 - b_i$ sums to $25 - 13 = 12$.
- Using $(1 - x^6)^5 (1 - x)^{-5}$ instantly encodes Inclusion-Exclusion on $b_i \ge 6$ without needing to list cases:
  $$\binom{17}{4} - 5\binom{11}{4} + 10\binom{5}{4} = 2380 - 1650 + 50 = \mathbf{780}.$$

## Common Mistakes

- **Forgetting to factor out $x^5$**: Computing $[x^{18}]$ in $(1-x^6)^5(1-x)^{-5}$ instead of $[x^{13}]$ corresponds to $0 \le a_i \le 5$ rather than $1 \le a_i \le 6$.
- **Missing the third term $+10\binom{5}{4}$**: Stopping after $-5\binom{11}{4}$ misses the case where two dice exceed $6$ ($6+6 = 12 \le 13$), giving $730$ instead of $780$.