Proof without using Stone-Weierstrass theorem. I came across the following problem. Let $f$ be a real valued continuous function on $[0,1]$. If for every whole number $n\in\{0,1,2,\cdots\}$,
$$\int_{0}^{1}f(x)x^ndx=0$$ then prove that $f(x)=0$ for all $x\in[0,1]$.
I proved this using the Stone-Weierstrass theorem. For every $n\in \mathbb{N}$ there exists a polynomial $P_n(x)$ such that $\sup_{x\in[0,1]}|P_n(x)-f(x)|<\frac{1}{2^n}$. Then $$\int_{0}^{1}(f(x))^2dx=\int_{0}^{1}f(x)P_n(x)dx+\int_{0}^{1}f(x)(f(x)-P_n(x))dx=\int_{0}^{1}f(x)(f(x)-P_n(x))dx\leq\frac{1}{2^n}\int_{0}^{1}|f(x)|dx.$$ Hence $\int_{0}^{1}(f(x))^2dx=0$ which implies $f(x)=0$ for all $x\in[0,1]$.
Can this problem be done without using Stone-Weierstrass theorem? 

Suppose $f$ is not identically $0$.  Take $p \in [0,1] $ such that $f(p) \ne 0$; WLOG $f(p) > 0$.  By continuity there are $a,b$ with $0 \le a < b \le 1$ such that
$f > 0$ on $[a,b]$.  Let $g(x) = 1 + c (b-x)(x-a)$ where $c > 0$ is small enough so that $|g(x)| < 1$ outside the interval $[a,b]$.  Of course $g(x) > 1$ on $(a,b)$.  Now for every $n$ we have $\int_0^1 g(x)^n f(x)\; dx = 0$.  But $\int_0^a g(x)^n f(x)\; dx \to 0$ and $\int_b^1 g(x)^n f(x)\; dx \to 0$ as $n \to \infty$, while
$\int_a^b g(x)^n f(x)\; dx \to +\infty$.
