Problem

Source: Turkey EGMO TST 2020 P2

Tags: function, number theory



$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$$