Solution (source code)

= Solution

Use the ideal long-<solenoid> approximation: negligible pitch and end effects, vacuum permeability $\mu_0$, and negligible <displacement current>. By cylindrical symmetry the <magnetic field> is axial. An <Ampère's law> rectangular loop with one axial side inside and the other outside gives $B_{\rm in}-B_{\rm out}=\mu_0NI$. A loop wholly outside shows the outside axial field is constant with radius; requiring it to vanish far away gives
$$
 \boxed{\mathbf B_{\rm in}=\mu_0NI\,\widehat{\mathbf z},\qquad
 \mathbf B_{\rm out}=0.}
$$
The axial sign is determined by the winding direction and the <right-hand rule>. The small axial component of current from the spiral pitch is neglected in this idealization.

There are $Nl$ turns, and the <magnetic flux> through each is $\pi a^2\mu_0NI$. The flux linkage is $LI$, so the <self-inductance> is
$$
 \boxed{L=\mu_0N^2\pi a^2l.}
$$
The induced <electromotive force> opposes increasing current by <Faraday's law>. Together with <Ohm's law>, the circuit equation is $L\dot I+RI=\mathcal E_0$. Solving this first-order <ordinary differential equation> with $I(0)=0$ gives
$$
 \boxed{I(t)=\frac{\mathcal E_0}{R}\left(1-e^{-Rt/L}\right),\qquad t\geq0.}
$$
The <time constant> is $L/R$, and the limiting current is $\mathcal E_0/R$.