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.

Your assumptions imply that
$$\int_0^1 (f(x)-x)x^ndx=0$$
for all $n$.  Now deduce that $f(x)-x=0$.  The standard way to do that is to approximate $f(x)-x$ with a polynomial sequence $p_n(x)$ and then deduce that
$$\int_0^1 (f(x)-x)^2dx=0$$
since
$$\int_0^1 (f(x)-x)p_n(x)dx=0$$
for each $n$
