problem using Weierstrass-Approximation 
Prove that $$\int_0^1 f(x)x^ndx=\frac{1}{n+2}$$ for each $n=0,1,2,\cdots \implies$ $f(x)=x$ on $[0,1]$


my attempt: for some sequence of coefficients $(a_n)$, choose some polynomial $p_n(x)=a_0+a_1x+...+a_nx^n$ such that $p_n\to f$ uniformly by Weierstrass-Approximation. Then $\int_0^1f(x)p_n(x)dx=\sum_{k=0}^n\frac{a_k}{k+2}$. and I'm stuck here.

You want to prove that $f(x) = x$, so prove that
$$
\int_0^1 (f(x) - x)^2 dx = 0
$$
You can write $f(x) - x =\lim \sum_k a_{k,n} x^k $ where the limit is uniform (and for each $n$ a finite number of $a_{k,n}$ is $\neq 0$).
This gives you access to:
$$
\begin{align}
\int_0^1 (f(x) - x)^2 dx &= \lim \int_0^1 (f(x) - x) \sum_k a_{k,n}x^k dx
\\&= \lim \sum_k a_{k,n} \int_0^1 (f(x)-x)x^k dx
\\ &= 0
\end{align}
$$
