Find all $f:\mathbb{N} \to \mathbb{N}$ such that $f(m)^2 + f(n) \mid (m^2+n)^2;\; \forall n,m \in \mathbb{N}$ 
Find all $f:\mathbb{N} \to \mathbb{N}$ such that $f(m)^2 + f(n) \mid (m^2+n)^2;\; \forall n,m \in \mathbb{N}$ 

I tried to write $k(f(m)^2 + f(n)) = (m^2 + n) ^2$ and tried to find if there is any fixed $k$ but failed. I can't find a way to start. 
 A: Let $P(m,n)\implies f(m)^2+f(n)\mid (m^2+n)^2$.
So $P(1,1)\implies f(1)^2+f(1)\in \{2,4\}$. These cases give only one natural number solution $f(1)=1$.
Now let $p\in\mathbb P$. Then $P(1,p-1)\implies f(p-1)+1\mid p^2 \implies f(p-1)\in\{p-1,p^2-1\}$. 
If $f(p-1)=p^2-1$ then $P(p-1,1)\implies p^4-2p^2+2\mid p^4-4p^3+8p^2-8p+4$. This implies
$$p^4-2p^2+2 \le p^4-4p^3+8p^2-8p+4\implies -4p^3+10p^2-8p+2\ge 0$$ 
which is never true for any $p>1$. Hence we deduce that $f(p-1)=p-1, ~\forall p\in \mathbb P$. 
Now take a fixed $n\in\mathbb N$ and then for any $p\in\mathbb P$
$$P(p-1,n)\implies 0\equiv ((p-1)^2+n)^2\equiv(f(n)-n)^2 \pmod{(p-1)^2+f(n)}$$ 
Since $p$ is unbounded whilst $f(n)-n$ is bounded, we must have $f(n)-n=0\implies f(n)=n,~\forall n\in\mathbb N$.
A: (Note the obvious fact that the identity does satisfy the requirements.)
This is a partial answer, whose result suffices to show that $f(n) = n$ for all $n \leq 100000$.
Letting $n = m^2$, we obtain $f(m)^2 + f(m^2) \mid 4m^4$, and in particular $f(1)^2 + f(1) \mid 4$. It's easy to check that $f(1) = 1$ is the only possibility, since $f(1) > 1$ means $f(1)^2 + f(1) > 4$.

Letting $n=1$, we obtain $f(m)^2 + 1 \mid (m^2 + 1)^2$.
So if $m^2+1$ is prime, then $f(m)^2+1 = m^2+1$ or $(m^2+1)^2$; so $f(m) = m$ or $f(m)^2+1$ is square (a contradiction).
Therefore if $m^2+1$ is prime, then $f(m) = m$.
Similarly, if $m^2+2$ is prime, then $f(m) = m$ (since the other option is $f(m)^2+2 = (m^2+2)^2$, a contradiction since no squares differ by $2$).
Similarly, if $m^2+3$ is prime, then $f(m) = m$ or $f(m)^2 + 3 = (m^2 + 3)^2$. The second case is no longer an instant contradiction, but it requires that $f(m) = 1$ and $m^2 + 3 = 2$, which is a contradiction.
We now generalise this, by showing that if there is a prime between $m^2$ and $m^2 + m$, and if $f(n) = n$ for all $n < m$, then $f(m) = m$.

Suppose there is a prime $p$ between $m^2$ and $m^2+m$.
Then let $n = p-m^2$, so by inductive hypothesis (since $n < m$) we have that $f(n) = n$.
We have $f(m)^2 + p-m^2 \mid p^2$, so one of the following three is true:

*

*$f(m)^2 + p - m^2 = 1$ (so $f(m)^2 = 1+m^2-p = 1-n < 0$, a contradiction),

*$f(m)^2 +p-m^2 = p$ (so $f(m) = m$), or

*$f(m)^2 + p - m^2 = p^2$.

This latter case ("Case 3") is the one we want to disprove, of course.
Case 3 is false
Case 3 implies that $p(p-1) = (f(m) + m)(f(m)-m)$; since $p$ is prime, that means $p$ divides one of those brackets. It can't divide $f(m)-m$, since that would make $f(m) + m$ greater than $p$ and therefore the right-hand side would be too big to equal the left-hand side; hence $p \mid f(m) + m$.

Lemma: $p = f(m)+m$, not just $p \mid f(m)+m$.
Proof: If $p \not = f(m) + m$, then we have $f(m) + m \geq 2p > 2m^2$; so $f(m) > 2m^2 - m$. Then $$p(p-1) = f(m)^2 - m^2 > (2m^2-m)^2 - m^2 = 4m^3(m-1)$$
but $p \in (m^2, m^2+m)$, and $p-1 \in [m^2, m^2+m-1)$, so $p(p-1)$ cannot be greater than or equal to $4m^3(m-1)$, let alone $f(m)^2 - m^2$.

Hence Case 3 implies that $f(m) = p-m$; since $p(p-1) = (f(m)+m)(f(m)-m)$, we must also have $p-1 = f(m)-m$, and hence $m = 1-m$, a contradiction.

The above shows that if there is a prime between $m^2$ and $m^2 + m$, and if $f(n) = n$ for all $n < m$, then $f(m) = m$.
We have already shown that $f(1) = 1$, but the question of whether there is a prime between $m^2$ and $m^2 + m$ is a stronger version of Legendre's conjecture which is unproven. There is probably a better way.
