Ramanujan posed the following formulas as questions in the Journal of Indian Mathematical Society:
$$\int_{0}^{\infty}\dfrac{\sin nx\,\,dx}{{\displaystyle x + \dfrac{1}{x +}\dfrac{2}{x +}\dfrac{3}{x +}\dfrac{4}{x + \cdots}}} = \dfrac{\sqrt{\dfrac{\pi}{2}}}{n + \dfrac{1}{n +}\dfrac{2}{n +}\dfrac{3}{n +}\dfrac{4}{n + \cdots}}\tag{1}$$ $$\int_{0}^{\infty}\dfrac{\sin\left(\dfrac{\pi nx}{2}\right)\,\,dx}{{\displaystyle x + \dfrac{1^{2}}{x +}\dfrac{2^{2}}{x +}\dfrac{3^{2}}{x +}\dfrac{4^{2}}{x + \cdots}}} = \dfrac{1}{n +}\dfrac{1^{2}}{n +}\dfrac{2^{2}}{n +}\dfrac{3^{2}}{n + \cdots}\tag{2}$$
From this post we know that $$\phi(x) = e^{x^{2}/2}\int_{x}^{\infty}e^{-t^{2}/2}\,dt = \frac{1}{x +}\frac{1}{x +}\frac{2}{x +}\frac{3}{x + \cdots}\tag{3}$$ and hence the first integral formula reduces to $$B = \int_{0}^{\infty}\phi(x)\sin nx\,\,dx = \sqrt{\frac{\pi}{2}}\phi(n) = \phi(n)\int_{0}^{\infty}e^{-t^{2}/2}\,dt\tag{4}$$ Considering the integral $$A = \int_{0}^{\infty}\phi(x)\cos nx\,\,dx$$ we can see that \begin{align} A + iB &= \int_{0}^{\infty}e^{x^{2}/2 + inx}\int_{x}^{\infty}e^{-t^{2}/2}\,dt\,dx\notag\\ &= e^{n^{2}/2}\int_{0}^{\infty}e^{(x + in)^{2}/2}\int_{x}^{\infty}e^{-t^{2}/2}\,dt\,dx\notag \end{align}
I am not so much used to theory of complex integration, but I think it should be possible to interchange the limits of integration above and get the values of $A$ and $B$ without going too much into the theory of complex integration. But still it does not seem rigorous to me. Please let me know if I am on the right track (or may be this approach can be made rigorous) or suggest alternative approach.
For integral $(2)$ I have no idea of the continued fraction used there. Any clues to the solution of $(2)$ would also be greatly helpful.