Dynamics of the pendulum with periodically varying length