Lemma › Techniques › Generating Functions
Olympiad problem-solving technique

Generating Functions

Turn a sequence into a single function.

Encode a sequence a0,a1,a2,…a_0, a_1, a_2, \dots as the coefficients of a power series ∑anxn\sum a_n x^n. Recurrences become algebraic equations, convolutions become products, and the answer falls out of a coefficient extraction.

The workhorse identities: 11−x=∑xn\frac{1}{1-x} = \sum x^n and 1(1−x)k=∑(n+k−1k−1)xn\frac{1}{(1-x)^k} = \sum \binom{n+k-1}{k-1} x^n. The second is stars and bars in disguise.

Best deployed when a counting problem has an awkward constraint that is easy to write as a factor of a product.

Where it appears on Lemma: Level 7 (recurrences) and Level 8 (combinatorics).

Train it on Lemma

Generating Functions unlocks at Level 7 of Lemma's eight-level ladder, with lessons that teach it and drills that make it stick. 125 lessons, 1206 curated problems and unlimited generated practice at six difficulties. Free to start, no card, and every paid plan opens with 3 free days.

Find your level

More techniques