# Using generating functions, find the number of solutions of the equation

so I've searched a lot about this and I've seen a few solutions but I didn't understand any of them.

I have this equation which I'm meant to use generating functions to find the number of solutions of this equations:

u1 + u2 + ... + u7 = 16, where 1<= ui <= 5 and i= 1, ..., 7. (I've also included a screenshot of the question for more clarity.

https://gyazo.com/0b1922b9c01d99487e095353aca5a079

So I know I have sample solutions for similar questions but I can't follow their working. Here is a sample solution: https://gyazo.com/babd84f939d4a8df3c83730c5ef4e802

I can do all the way up line 5 of the solution section but I don't understand how g(X) returns that function and then also how do they get the solution from g(X) ???

Hint: consider $$(u+u^2+...+u^5)^7$$, specifically the coefficient in front of $$u^{16}$$.
• That’s a nice reduction as you now need to find the $u^9$ coefficient of the second piece. To do so you could either brute force the expansion (discarding anything bigger than $u^9$ along the way) or you could take 9 derivatives and evaluate at 0. – Alex R. May 4 at 5:09
• I’m dividing both sides by $u^7$ (or $X^7$) in your notation. – Alex R. May 4 at 5:14