Solution (source code)

= Solution

Take $B>0$ and use the <Landau gauge> $\mathbf A=(0,Bx,0)$. With zero $z$-momentum, the Hamiltonian becomes
$$
H=\frac1{2m}\left[p_x^2+(p_y+eBx)^2\right].
$$
For a state $e^{ik_y y}\chi(x)$, this is a <quantum harmonic oscillator> in $x$, centred at
$$
x_0=-\frac{\hbar k_y}{eB},
$$
with <cyclotron frequency>
$$
\omega_c=\frac{|eB|}{m}.
$$
The <Landau level>[Landau levels] are therefore
$$
\boxed{E_n=\hbar\omega_c\left(n+\frac12\right)},
\qquad n=0,1,2,\ldots.
$$

Periodicity in $y$ quantizes $k_y=2\pi\ell/R_y$. Requiring the corresponding oscillator centre to lie in an $x$ interval of length $R_x$ leaves
$$
\boxed{D=\frac{|eB|R_xR_y}{2\pi\hbar}}
$$
allowed centres for each $n$. This is the <degeneracy of a Landau level>, equal to the magnetic flux through the rectangle divided by the <magnetic flux quantum> $h/|e|$. Consistent magnetic periodic boundary conditions make $D$ an integer.