This problem is from Birkhoff and Maclane, A Survey of Modern Algebra, pg 21, problem 4*.
Given a function $w: \mathbb{Z}\backslash\{0\} \rightarrow \mathbb{N}$ that behaves like a discrete valuation function, i.e.,
(1) $ w(ab) = w(a) + w(b) $
(2) $ w(a+b) \geq \min(w(a), w(b)).$
Show that it is either
- constant $0$ function, $w(a) = 0$ or
- a multiple of a $p$-adic valuation, in other words $w(a) = k v_p(a)$ for some $p, k$ with $v_p(p^nd) = n $ when $(p, d) = 1 $.
More interesting is the variant of this problem described here.
From $(1)$ we have $w(1)=w(1)+w(1)$, hence $w(1)=0$. Then we have $w(1)=w(-1)+w(-1)$, hence $w(-1)=0$. So we have $w(-n)=w(-1)+w(n)=w(n)$ and need only check positive integers.Also, this allows us to generalize $(2)$ to $$\tag{2'}w(a\pm b)\ge\min\{w(a),w(b)\}\qquad\text{if }a\pm b\ne 0.$$
Let $a$ be the smallest positive integer with $w(a)>0$ (if no such $a$ exists, then $w=0$ and we are done). Clearly, $a>1$ as $w(1)=0$. Thus $a$ is either composite or prime. If $a$ is composite, $a=a_1a_2$ with $1<a_1,a_2<a$, then $w(a)=w(a_1)+w(a_2)$ implies that one of $w(a_1),w(a_2)$ is nonzero, contradicting minimality. Hence $a$ is (once again) a prime.
Let $b$ be the smallest positive integer with $w(b)\ne v_a(b)$ (if no such $b$ exists, we have $w=v_a$ and are done). If $a|b$ then $w(\frac ba)=w(b)-w(a)\ne v_a(b)-v_a(a)=v_a(\frac ba)$ contradicting minimality of $b$. Therefore $v_a(b)=0$ and hence $w(b)>0$. By minimality of $a$ we have $b>a$, hence $b-a>0$. Now $w(b-a)\ge \min\{w(b),w(-1)+w(a)\}>0$. Since $a\not\mid b-a$ we conclude $w(b-a)\ne v_a(b-a)$ contradicting minimality of $b$.