We develop a scheme to exactly evaluate the correlation energy in the random-phase approximation, based on linear response theory. It is demonstrated that our formula is completely equivalent to a contour integral representation recently proposed by Donau et al. being numerically more efficient for realistic calculations. Numerical examples are presented for pairing correlations in rapidly rotating nuclei.