Answer
$n=2 $
Work Step by Step
The change in energy when the transition occurs is equal to the energy of the photon emitted.
$\implies \frac{hc}{\lambda}=2.18\times10^{-18}\,J(\frac{1}{n_{f}^{2}}-\frac{1}{n_{i}^{2}})$
$\implies \frac{(6.626\times10^{-34}\,J\cdot s)(3.00\times10^{8}\,m/s)}{397\times10^{-9}\,m}=$
$2.18\times10^{-18}\,J(\frac{1}{n_{f}^{2}}-\frac{1}{7^{2}})$
$\implies 5.007\times10^{-19}\,J+\frac{2.18\times10^{-18}\,J}{49}=\frac{2.18\times10^{-18}\,J}{n_{f}^{2}}$
$\implies 5.4519\times10^{-19}\,J=\frac{2.18\times10^{-18}\,J}{n_{f}^{2}}$
Then,
$n_{f}^{2}=\frac{2.18\times10^{-18}\,J}{5.4519\times10^{-19}\,J}=4$
$\implies n_{f}=2$