> [!Question] Problem (Belarus, 1997)
> Find all function $g:\mathbb{R}\to\mathbb{R}$ such that for all $x,y\in \mathbb{R},$ $g(x+y)+g(x)g(y)=g(xy)+g(x)+g(y).\tag{1}$
**Solution**
Let $c\in \mathbb{R},$ such that $2c=c^{2}.$ Then plugging $x=y=c$ gives $g(c)^{2}=2g(c)$ which gives $g(c)\in \{ 0,2 \}.$ In particular, $g(2)$ equals $2$ or $0.$
Plugging $y=1$ gives that for all $x\in \mathbb{R},$ $g(x+1)=(2 -g(1)) g(x) + g(1).\tag{2}$
Plugging $x=y=1$ gives $g(1)^{2}-3g(1)+g(2)=0.$ If $g(2)=0,$ then $g(1)=0$ or $g(1)=3$ and if $g(2)=2,$ then $g(1)=1$ or $g(1)=2.$ Consider the possible cases:
1. Suppose $g(2)=0$ and $g(1)=3.$ Then $(2)$ yields $g(x+1)=3-g(x).$ This yields $g(x+2)=3-g(x+1)=3-(3-g(x))=g(x).$ Plugging $x=\frac{1}{2}$ and $y=2$ in $(1)$ gives $g(1)=0$ - a contradiction. So this case can't happen.
2. Suppose $g(2)=0$ and $g(1)=0.$ Then $(2)$ yields $g(x+1)=2g(x)$ which yields inductively $g(x+n)=2^{n}g(x)$ for any integer $n.$ On the other hand, $g(nx)=(2^{n}-1)g(x).$ Thus $2^{2n}3g(x)=2^{2n}g(2x)=g(2x+2n)=3g(x+n)=2^{2n}3g(x)$which gives $g(x)=0$ for all real $x.$
3. Suppose $g(2)=2$ and $g(1)=2.$ Then $(2)$ yields $g(x+1)=2$ so $g(x)=2$ for all real $x.$
4. Suppose $g(2)=2$ and $g(1)=1.$ Then $(2)$ yields $g(x+1)=g(x)+1$ which yields inductively, $g(x+n)=g(x)+n$ for all integers $n$ and $g(nx)=ng(x).$ Substituting $x$ for $2x$ and $y$ for $2y,$ $(1)$ yields $2g(x+y)+4g(x)g(y)=2g(x)+2g(y)+4g(xy).$Subtracting this from $(1)$ gives $g(xy)=g(x)g(y)$and subtracting this gives $g(x+y)=g(x)+g(y).$By [[Real Function That is Both Additive and Multiplicative is either Zero or The Identity]], $g(x)=x$ or $g(x)=0.$