$p(m)$ is the number of distinct prime divisors of a positive integer $m>1$ and $f(m)$ is the $\bigg \lfloor \frac{p(m)+1}{2}\bigg \rfloor$ th smallest prime divisor of $m$. Find all positive integers $n$ satisfying the equation: $$f(n^2+2) + f(n^2+5) = 2n-4$$
Problem
Source: Turkey EGMO TST 2020 P2
Tags: function, number theory
06.02.2020 13:20
18.02.2020 17:19
Check the cases $n=1,2,\dots,7,8$ manually to see $n=5$ is the only one among them satisfying the condition. Furthermore, if either $n^2+2$ or $n^2+5$ is a prime, left hand side is bigger than right hand size. The key idea is the following: $f(n)\leqslant \sqrt{n}$ for every composite $n$. To see this, if $n$ is a prime power, the conclusion follows immediately. If $n$ is not a prime power, and $f(n)>\sqrt{n}$, it also follows that $p(m)^{th}$ (distinct) prime divisor of $n$ is also larger than $\sqrt{n}$, a contradiction. Equipped with this, we now attack the problem. If $f(n^2+2)=n$ then $n\mid n^2+2$, that is, $n\mid 2$, handled already. If $f(n^2+2)=n-1$ then $n-1\mid n^2+2$ and thus $n-1\mid 3$, $n\leqslant 4$, also handled already. Finally, if $f(n^2+2)=n-2$, then $n-2\mid n^2+2$ and thus $n-2\mid 6$, handled already. Thus $f(n^2+2)\leqslant n-3$. Similarly, if $f(n^2+5)=n$, then $n\mid n^2+5$, that is $n\mid 5$, handled already. If $f(n^2+5)=n-1$ then $n-1\mid n^2+5$, implying $n-1\mid 6$, that is $n\leqslant 7$ handled already. Thus $f(n^2+5)\leqslant n-2$ and $f(n^2+2)\leqslant n-3$, and thus $f(n^2+2)+f(n^2+5)<2n-4$. Thus, $n=5$ is the only possibility.