Subfield: Algebra


Question: Let $\mathbb{N}=\{1,2,3, \ldots\}$ be the set of all positive integers. Find all functions $f: \mathbb{N} \rightarrow \mathbb{N}$ such that for any positive integers $a$ and $b$, the following two conditions hold:

(1) $f(a b)=f(a) f(b)$, and

(2) at least two of the numbers $f(a), f(b)$ and $f(a+b)$ are equal.

Solution:
First, all such functions $f$ satisfy the conditions, as $v_{p}(a) \neq v_{p}(b)$ implies $v_{p}(a+b)=$ $\min \left(v_{p}(a), v_{p}(b)\right)$. Plugging $a, b=1$ into (1) gives $f(1)=1$. Also, a simple induction gives that $f\left(\prod_{i=1}^{k} p_{i}^{a_{i}}\right)=\prod_{i=1}^{k} f\left(p_{i}\right)^{a_{i}}$. Let $S$ be the set of all primes $p$ such that $f(p) \neq 1$. If $|S|=1$, then $S=\{p\}$ and $f(p)=a$ for some $a \neq 1$, and thus $f(n)=a^{v_{p}(n)}$ for all $n$. If $S=\emptyset$ then $f(n)=1$ for all $n$, which can be also written in the above form for $a=1$.

Now suppose that $S$ contains at least two primes. Let $p<q$ be the two smallest elements of $S$. Since all prime divisors of $q-p$ are smaller than $q$ and not equal to $p, f(q-p)=1$. Using (2) for $p$ and $q-p$ gives us that some two of $f(p) \neq 1, f(p-q)=1$ and $f(q) \neq 1$ are equal, meaning that $f(p)=f(q)$. Let $t \geq 2$ be the smallest integer such that $p^{t}>q$, and let $p^{t}=a q+b$ with $0 \leq b<q$. Since $q \geq p^{t-1}$ and $q$ is not divisible by $p$, we have $q>p^{t-1}$, so $a<p$, and thus $f(a)=1$. Therefore $a q$ is not divisible by $p$, thus neither is $b$, and since $b<q, f(b)=1$. Now using (2) for $a q$ and $b$ we get that some two of $f(a q)=f(a) f(q)=f(q)=f(p), f(b)=1$ and $f(a q+b)=f\left(p^{t}\right)=f(p)^{t}$ are equal, which is a contradiction.
Suppose that there are two primes, $p<q$ such that $f(p)>1$ and $f(q)>1$, and these are the two smallest such primes.

$1<p-q<q$ and it is not divisible by $p$ and $q$, therefore its prime factors are smaller than $q$ so we conclude $f(q-p)=1$. By $(2)$, two of $f(q-p)=1, f(q-p)>1$ and $f(q)>1$ are equal, so $f(q)=f(p)=a$.

If $p^{2}<q$ then $q-p^{2}$ is not divisible by $p$ and $q$, so we conclude $f\left(q-p^{2}\right)=1$ in the same way. Then $f\left(p^{2}\right)=f(p)^{2}=a^{2}, f\left(q-p^{2}\right)=1$ and $f(q)=a$ are distinct, contradicting (2). Hence, $q<p^{2}$.

Let $c=\left\lfloor p^{2} / q\right\rfloor$; then $0<c<p$, so $f(c)=1$. By $0<p^{2}-c q<q$, we get $f\left(p^{2}-c q\right)=1$. Now $f\left(p^{2}-c q\right)=1, f\left(p^{2}\right)=a^{2}$ and $f(c q)=a$ are distinct, contradicting (2) again.
Suppose there exists a positive integer $n$ such that $f(n) \neq 1$ and $f(n+1) \neq 1$. We know that $f(1)=1$, so by (2) two of $f(n) \neq 1, f(n+1) \neq 1$ and $f(1)=1$ are equal, therefore $f(n)=f(n+1)$.

$f\left(n^{2}\right)=f(n)^{2} \neq 1$ and $f\left(n^{2}-1\right)=f(n+1) f(n-1)=f(n) f(n-1) \neq 1$, but by (2) two of $f(1)=1, f\left(n^{2}-1\right) \neq 1$ and $f\left(n^{2}\right) \neq 1$ are equal, so $f\left(n^{2}-1\right)=f\left(n^{2}\right)$ and thus $f(n) f(n-1)=f(n)^{2}$, therefore $f(n-1)=f(n)$.

Then for $n-1$, it is also true that $f(n-1) \neq 1$ and $f(n-1+1) \neq 1$, so the same proof applies, $f(n-1-1)=f(n-1)$ and so on. By induction we get that $f(n)=f(1)$, which is a contradiction, as $f(1)=1$ and we assumed that $f(n) \neq 1$. Therefore, there can't be any $n$ for which $f(n) \neq 1$ and $f(n+1) \neq 1$.

Now suppose there are two primes, $p \neq q \in S$ such that $f(p) \neq 1$ and $f(q) \neq 1$. Then by the Chinese remainder theorem, there exists a number $n$ such that $p \mid n$ and $q \mid n+1$, so $f(p) \mid f(n)$ and $f(q) \mid f(n+1)$ thus $f(n) \neq 1$ and $f(n+1) \neq 1$. This is a contradiction, so $S$ can't have two distinct elements.
Claim 3.1. If $f(m)>1$ for some $m \in \mathbb{N}$, then there are less than $m$ different prime numbers $p_{i}$ with $f\left(p_{i}\right)>1$.

Proof. On the one hand, if $f(m)=c>1$, then for any $n \in \mathbb{N}$, there is some $k \in\{n+1, n+2 \ldots, n+m\}$ such that $f(k) \in\{1, c\}$. To show this, it is enough to see that condition (2) implies that for any $n \in \mathbb{N}$

- if $f(n)=c$, then $f(n+1) \in\{1, c\}$;
- if $f(n)=1$, then $f(n+m) \in\{1, c\}$.

On the other hand, if we suppose that there are $m$ different prime numbers $p_{1}, p_{2}, \ldots, p_{m}$, then we know (by the Chinese Remainder Theorem) that for any number $t \in \mathbb{N}$, there exists a number $n_{t} \in \mathbb{N}$ such that $p_{k}^{t} \mid n_{t}+k$ for each $k \in\{1,2, \ldots, m\}$. Hence for each $k$, we have

$$
f\left(n_{t}+k\right) \geq f\left(p_{i}^{t}\right)=f\left(p_{i}\right)^{t} \geq 2^{t}
$$

If $2^{t}>c$, then it means that $f(k)>c$ for all $k \in\left\{n_{t}+1, n_{t}+2 \ldots, n_{t}+m\right\}$.

Now we can suppose that for some $m \geq 2$, the set of primes with $f(p)>1$ is $S=\left\{p_{1}, p_{2}, \ldots, p_{m}\right\}$. Now let $S_{1}$ and $S_{2}$ be two disjoint nonempty subsets such that $S_{1} \cup S_{2}=S$. Let $a=\prod_{p_{i} \in S_{1}} p_{i}$ and $b=\prod_{p_{j} \in S_{2}} p_{j}$.

Now for any $k, \ell \in \mathbb{N}, a^{k}+b^{\ell}$ is coprime to all primes in $S$, hence $f\left(a^{k}+b^{\ell}\right)=1$. It is easy to see that we can choose $k$ and $\ell$ such that $f\left(a^{k}\right) \neq f\left(b^{\ell}\right)$, which contradicts condition (2).
Let $p$ the minimal (prime) number with $f(p)=c>1$.

Claim 4.1. For any $k \in \mathbb{N}, f\left(1+p+p^{2}+\ldots+p^{k}\right) \in\left\{1, c, c^{2}, \ldots, c^{k}\right\}$.

Proof of the claim. Use condition (2) recursively.

Now suppose that there exists some prime $q>p$ with $f(q)>1$, and consider the following three values of $f$ :

- $f(1)=1$.
- $f\left(p^{q-1}-1\right)=f(p-1) f\left(p^{q-2}+p^{q-3}+\ldots+p+1\right) \in\left\{1, c, c^{2}, \ldots, c^{q-2}\right\}$ using our claim, (note that we know $f(p-1)=1$ by the minimality of $p$ ).

But we also know (by Fermat's little theorem) that $q \mid p^{q-1}-1$, hence $f(q) \mid f\left(p^{q-1}-1\right.$ ). Therefore we have that: $f\left(p^{q-1}-1\right) \in\left\{c, c^{2}, \ldots, c^{q-2}\right\}$.

- $f\left(p^{q-1}\right)=c^{q-1}$.

These are three different values, hence we have a contradiction by condition (2).
Let $p$ the minimal (prime) number with $f(p)=c>1$.

Lemma 4B.1. For any $k \in \mathbb{N}, f\left(1+p+p^{2}+\ldots+p^{k}\right)=1$.

Proof of the Lemma, by induction. $k=0$ is trivial.

$k=1$ is also easy, as $p+1$ cannot be a prime, except in the case of $p=2$, which is also easy. (If $f(2)=c>1$, then $f(3) \in\{1, c\}$ by $3=1+2$ and $f(3) \in\left\{1, c^{2}\right\}$ by $2^{2}=1+3$.)

From now we suppose $k \geq 2$ and $f\left(1+p+\ldots+p^{k-1}\right)=1$. By condition (2), we have that:

- As $f\left(1+p+\ldots+p^{k-1}\right)=1$ and $f\left(p^{k}\right)=c^{k}$,

we have that $f\left(1+p+\ldots+p^{k-1}\right) \in\left\{1, c^{k}\right\}$

- As $f(1)=1$ and $f\left(p+\ldots+p^{k}\right)=f(p) f\left(1+p+\ldots+p^{k-1}\right)=c$,

we also have that $f\left(1+p+\ldots+p^{k-1}\right) \in\{1, c\}$.

If $k>1, c \neq c^{k}$, therefore $f\left(1+p+\ldots+p^{k}\right)=1$.

Now suppose that there exists some prime $q>p$ with $f(q)>1$. Then by condition (1),

$$
f\left(p^{q-1}-1\right)=f(p-1) f\left(1+p+\ldots+p^{q-2}\right)
$$

here $f(p-1)=1$ (by the minimality of $p$ ) and $f\left(1+p+\ldots+p^{q-2}\right)=1$ by the lemma. But we also know (by Fermat's little theorem) that $q \mid p^{q-1}-1$, hence $1<f(q) \leq f\left(p^{q-1}-1\right.$ ), which is a contradiction.
Lemma 5.1. If $f(m) \neq f(n)$, then $f(n+m)=f(n-m)$ (for all $n>m \in \mathbb{N}$ ).

Proof of the Lemma. By condition (2), $\{f(n+m), f(n-m)\} \subseteq\{f(n), f(m)\}$. We also have that:

$$
f(n-m) f(n+m)=f\left(n^{2}-m^{2}\right) \in\left\{f(n)^{2}, f(m)^{2}\right\}
$$

which is only possible if $f(n-m)=f(n+m)=f(n)$ or $f(n-m)=f(n+m)=f(m)$.

Now let $p$ be the smallest (prime) number with $f(p)>1$.

Claim 5.2. If $p$ does not divide $n$, then $f(n)=1$.

Proof of the Claim. Let $n$ be the minimal counterexample, and and let $n=d p+r$ with $0<r<p$. Here $d \geq 1$ by the minimality of $p$.

Now $1<f(d) f(p)=f(d p) \neq f(r)=1$, hence by our lemma, $f(d p+r)=f(d p-r)=1$, contradiction.

Final answer: $f(n)=a^{v_{p}(n)}$, where $a \in \mathbb{N}, p$ is a prime and $v_{p}(n)$ is the largest exponent of $p$ dividing $n$