Finding a generating function for number of existing integers

combinatoricsgenerating-functions

Let $k$ be a positive integer. $\left \{ a_r \right \} _{r=0}^{\infty}$ is the number of integers which exist between $0$ and $10^k$ (i.e integers with no more than $k$ digits), such that the sum of their digits is no more than $r$.

Find the generating function for $\left \{ a_r \right \} _{r=0}^{\infty}$.

A very similar question has been asked here.

It is clear to me that we can define $f(x) = (1+x+x^2+\dots+x^9)^{k}$ and this would be a generating function for the problem "how many integers exist with exactly the sum $r$". Meaning that would be the coefficient of $x^r$.

So using this I believe we can express $a_r$, but the question is to find a generating function for $a_r$.

So is this still a good direction, or should I think about the problem differently?

Best Answer

If we denote the number of integers with sum no more than $r$ by $a_r$ and the number of integers with sum exactly $r$ by $b_r$, we have

$$ a_r=\sum_{k=0}^rb_k\;. $$

You know the generating function for $b_k$. Summing a sequence corresponds to multiplying its generating function by $\sum_{k=0}^\infty x^k=\frac1{1-x}$. Thus the generating function you want is

$$ \frac{\left(1+\cdots+x^9\right)^k}{1-x}=\frac{\left(1-x^{10}\right)^k}{(1-x)^{k+1}}\;. $$

Note that this is also an intermediate result that Markus Scheuer arrived at in line $(6)$ in his answer to the question you linked to. He included $10^k$ instead of $0$, but the result is the same.

Related Question