suppose $$|r - \sqrt n| < M < 9(\sqrt n)$$ with M, r ∈ N
prove that:
max of $|r^2 - n|$ is at most $(M-1)^2 + 2*M* ceil\sqrt n$ and
average of $|r^2 - n|$ is $M * (floor(\sqrt n) + ceil(\sqrt n))/2$
I'm assuming this has something to do with the fact that $(r+\sqrt n)(r - \sqrt n) = r^2- n$ but I'm not sure what to do with this information.