Let $n \in \mathbb{N}$. We consider $n+1$ distinct points in $I$, denoted $x_0 < x_1 < \cdots < x_n$, and the Lagrange basis $(L_0, \ldots, L_n)$ associated with these points.
Suppose that, for all $k \in \mathbb{N}$, the map $x \mapsto x^k w(x)$ is integrable on $I$. Show that the quadrature formula $I_n(f) = \sum_{j=0}^n \lambda_j f(x_j)$ is exact on $\mathbb{R}_n[X]$ if and only if
$$\forall j \in \llbracket 0, n \rrbracket, \quad \lambda_j = \int_I L_j(x) w(x)\,\mathrm{d}x.$$