We present a pendulum iterative algorithm (PIA) to solve the phase retrieval problem. Computer simulations show that, in general, PIA converges faster than previous iterative algorithms in which the moduli of the object and the Fourier domain are provided. The performance of the PIA is compared with that of the error-reduction algorithm (ERA), the modified error-reduction algorithm (MERA), the input-output algorithm (IOA), and the hybrid IOA/ERA algorithm. We show that the PIA generally performs better for a binary modulus. In the case of a multilevel modulus, the PIA performs comparable to the hybrid IOA/ERA, while better than the others.