  We study dynamics of a nonlinear pendulum under a periodic force with small
amplitude and slowly decreasing frequency. It is well known that when the
frequency of the external force passes through the value of the frequency of
the unperturbed pendulum's oscillations, the pendulum can be captured into the
resonance. The captured pendulum oscillates in such a way that the resonance is
preserved, and the amplitude of the oscillations accordingly grows. We consider
this problem in the frames of a standard Hamiltonian approach to resonant
phenomena in slow-fast Hamiltonian systems developed earlier, and evaluate the
probability of capture into the resonance. If the system passes the resonance
at small enough initial amplitudes of the pendulum, the capture occurs with
necessity (so-called autoresonance). In general, the probability of capture
varies between one and zero, depending on the initial amplitude. We demonstrate
that a pendulum captured at small values of its amplitude escapes from the
resonance in the domain of oscillations close to the separatrix of the
pendulum, and evaluate the amplitude of the oscillations at the escape.
