On this page
Many JEE counting questions share one structure: several choices, each adding to a total, with limits on each. Generating functions turn that into algebra. As MathWorld puts it, a generating function is a formal power series whose coefficients give a sequence of numbers. In counting, the coefficient of xⁿ is the number of ways to reach a total of n.
How do you set up a generating function for a counting problem?
Write one bracket for each source: each die, child or type of object.
Inside it, put xᵏ for every amount k that source may contribute. "At least 2" starts the bracket at x²; "at most 9" stops it at x⁹.
Multiply the brackets. Exponents add, so totals add as the problem demands.
The answer is the coefficient of x raised to the target total.
Two identities do almost all of the extraction work:
1 + x + x² + … + xᵐ = (1 − xᵐ⁺¹)/(1 − x)
The coefficient of xʳ in (1 − x)⁻ⁿ is C(n + r − 1, r)
The second is stars and bars, so this method agrees with what you know about distributing identical objects into groups.
How many ways can three dice show a sum of 10?
One die is x + x² + … + x⁶, one power for each face. Plus magazine explains why multiplying works: to sum two dice you multiply their polynomials, because xᵃ·xᵇ = xᵃ⁺ᵇ. MathWorld's dice page gives the general form (x + x² + … + xˢ)ⁿ for n dice with s sides.
For three dice, (x + … + x⁶)³ = x³(1 − x⁶)³(1 − x)⁻³. Pull out the x³, so you need the coefficient of x⁷ in (1 − 3x⁶ + 3x¹² − x¹⁸)(1 − x)⁻³.
From the 1: C(9, 2) = 36
From the −3x⁶: −3 × C(3, 2) = −9
The x¹² and x¹⁸ terms are too large to matter
So the answer is 36 − 9 = 27, matching MathWorld's probability of 1/8 (27 of 216 outcomes) and this full expansion of the three-dice polynomial, which lists 27x¹⁰. The same steps for a total of 15 give C(14, 2) − 3·C(8, 2) + 3·C(2, 2) = 91 − 84 + 3 = 10. The (1 − x⁶)³ factor is inclusion-exclusion in disguise: the −3x⁶ term removes cases where a die would show more than 6.
How do generating functions handle distributions with limits?
JEE Main 2024 (31 January, shift 2) asked for the number of ways 21 identical apples can be distributed among three children so that each child gets at least 2. The answer is 136.
Each child's bracket starts at x²: (x² + x³ + …)³ = x⁶(1 − x)⁻³. You need the coefficient of x²¹, which is the coefficient of x¹⁵ in (1 − x)⁻³: C(17, 2) = 136.
Now our own harder variation: add "no child gets more than 9". Each bracket becomes x² + … + x⁹ = x²(1 − x⁸)/(1 − x). The coefficient of x¹⁵ in (1 − x⁸)³(1 − x)⁻³ is C(17, 2) − 3·C(9, 2) = 136 − 108 = 28. The 3x¹⁶ term is already past x¹⁵.
How do you count selections with identical objects, like coins?
JEE Main 2019 (12 April, morning shift) asked for the number of ways of choosing 10 objects out of 31, where 10 are identical and 21 are distinct. The answer is 2²⁰.
Think of the 10 identical objects as identical coins. You may take 0 to 10 of them: 1 + x + … + x¹⁰. Each distinct object is taken or not: (1 + x). So the count is the coefficient of x¹⁰ in (1 + x + … + x¹⁰)(1 + x)²¹. Choose k distinct objects and fill the rest with coins, giving C(21, 0) + C(21, 1) + … + C(21, 10). Because C(21, k) = C(21, 21 − k), this is exactly half of 2²¹, which is 2²⁰. That symmetry step is covered in our guide to the binomial theorem for JEE.
When should you use generating functions in JEE?
Upper limits on parts (dice, marks, digit sums): use a generating function.
Only lower limits: subtract them and use stars and bars.
Identical and distinct objects mixed: one bracket per type.
Order matters: use permutation formulas, because these brackets count selections.
The usual error is the bracket, not the algebra: starting at x⁰ when the problem says "at least one", or forgetting an upper limit. If yours keeps going wrong, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer, so you can see where your bracket went off. For the habits behind most counting slips, read how to stop double counting in permutations and combinations.
Try one now: write the bracket for four dice with a total of 14 before you expand anything. You should get C(13, 3) − 4·C(7, 3) = 286 − 140 = 146.



