Step 1: Use the Rydberg formula for hydrogen:
\[
\frac{1}{\lambda}=R\left(\frac{1}{n_f^2}-\frac{1}{n_i^2}\right)
\]
Step 2: For transition from $n$ to first excited state ($n_f=2$):
\[
\frac{1}{\lambda_1}
=R\left(\frac{1}{2^2}-\frac{1}{n^2}\right)
=R\left(\frac{1}{4}-\frac{1}{n^2}\right)
\quad \cdots (1)
\]
Step 3: For transition from $n$ to ground state ($n_f=1$):
\[
\frac{1}{\lambda_2}
=R\left(1-\frac{1}{n^2}\right)
\quad \cdots (2)
\]
Step 4: Subtract equation (1) from (2):
\[
\frac{1}{\lambda_2}-\frac{1}{\lambda_1}
=R\left(1-\frac{1}{4}\right)
=\frac{3R}{4}
\]
Step 5: Eliminate $R$ using equation (2):
\[
R=\frac{1}{\lambda_2\left(1-\frac{1}{n^2}\right)}
\]
Substitute into Step 4 and simplify to obtain:
\[
n^2=\frac{4(\lambda_2-\lambda_1)}{4\lambda_2-\lambda_1}
\]
Step 6: Hence,
\[
n=\sqrt{\frac{4(\lambda_2-\lambda_1)}{4\lambda_2-\lambda_1}}
\]