Solution (source code)

= Solution

Use the generators $e,f,h$ of the <sl2 Lie algebra> with $[h,e]=2e$, $[h,f]=-2f$, and $[e,f]=h$. For a finite-dimensional <Lie algebra representation>, $h$ is diagonalizable with integral <weights>. Its <formal character of a weight module> is
$$
\boxed{\operatorname{ch}V=\sum_{m\in\mathbb Z}(\dim V_m)q^m,\qquad V_m=\{v:hv=mv\}.}
$$
Here $q$ is a formal variable; equivalently the expression is $\operatorname{tr}_V(q^h)$, or the formal sum $\sum_m(\dim V_m)e^m$ with $e^m=q^m$. This records every <weight multiplicity>, rather than only the <dimension>.

The <classification of finite-dimensional sl2 representations> says that $L_d$, the irreducible of <highest weight> $d\ge0$, has the <weight> string $d,d-2,\ldots,-d$, each with multiplicity one. Hence
$$
\operatorname{ch}L_d=q^d+q^{d-2}+\cdots+q^{-d}=\frac{q^{d+1}-q^{-(d+1)}}{q-q^{-1}}.
$$
The quotient denotes the displayed <Laurent polynomial> and has the removable value $d+1$ at $q=1$. <Formal characters> are additive on <direct sums>, so these formulas determine the character of every finite-dimensional module.