TITLE: Nonzero $f \in C([0, 1])$ for which $\int_0^1 f(x)x^n dx = 0$ for all $n$
QUESTION [35 upvotes]: As the title says, I'm wondering if there is a continuous function such that $f$ is nonzero on $[0, 1]$, and for which $\int_0^1 f(x)x^n dx = 0$ for all $n \geq 1$. I am trying to solve a problem proving that if (on $C([0, 1])$) $\int_0^1 f(x)x^n dx = 0$ for all $n \geq 0$, then $f$ must be identically zero. I presume then we do require the $n=0$ case to hold too, otherwise it wouldn't be part of the statement. Is there ay function which is not identically zero which satisfies $\int_0^1 f(x)x^n dx = 0$ for all $n \geq 1$?
The statement I am attempting to prove is homework, but this is just idle curiosity (though I will tag it as homework anyway since it is related). Thank you!

REPLY [9 votes]: There is a proof, using the Weierstrass approximation theorem, that if $f$ is continuous then $f$ is necessarily zero!                                                                                                                                                                                                                      
Classical Weierstrass's Theorem : If f is a continuous real valued function on $[a, b]$, then there exists a sequence of polynomials $p_n$ such that
$$ \lim_{n\rightarrow+\infty}p_n(x)=f(x)$$ uniformly on $[a, b]$.
By the assumptions of the problem and the linearity of the integral 
is easy to see that
$$ 
\int_{0}^1f(x)p(x)dx=0 
$$ 
for all polynomials $p(x)$ on $C([0,1])$. Now just apply Theorem!