Đặt \(\left\{{}\begin{matrix}n+1=a^2\\n+6=b^2\end{matrix}\right.\Rightarrow\left\{{}\begin{matrix}n=a^2-1\\n=b^2-6\end{matrix}\right.\Rightarrow a^2-1=b^2-6\)
\(\Rightarrow a^2-b^2=-6+1=-5\\ \Rightarrow\left(a-b\right)\left(a+b\right)=-5\cdot1=-1\cdot5\)
Vì \(n+1< n+6\Rightarrow a< b\Rightarrow a-b< a+b\)
\(\Rightarrow\left[{}\begin{matrix}\left\{{}\begin{matrix}a-b=-1\\a+b=5\end{matrix}\right.\\\left\{{}\begin{matrix}a-b=-5\\a+b=1\end{matrix}\right.\end{matrix}\right.\Rightarrow\left[{}\begin{matrix}\left\{{}\begin{matrix}a=2\\b=3\end{matrix}\right.\\\left\{{}\begin{matrix}a=-2\\b=3\end{matrix}\right.\end{matrix}\right.\Rightarrow n=3\)