Question: If $f$ is a function such that $$f(x+y) = f(x)+f(y) \qquad f(xy) = f(x)f(y)$$ for all $x$, then prove that $f(x) = 0$ or $f(x) = x$ for all $x$. (The fact that every positive number is a square of some number will be important.)
My attempt: I was able to show that this is satisfied for rational $x$ but we cant assume $f$ is continuous so can we prove this for all real $x$? Also, if I'm not mistaken, can I assume that $f(x) \ne 0$ or $f(x) \ne x$ for all $x$ and then prove that $f(x) = x$ or $f(x) = 0$ for all $x$ respectively?