We introduce a new algorithm for computing correlations of photon arrival time data acquired in single-molecule fluorescence spectroscopy and fluorescence correlation spectroscopy (FCS). The algorithm is based on rewriting the correlation as a counting operation on photon pairs and can be used with arbitrary bin widths and spacing. The flexibility of the algorithm is demonstrated by use of FCS simulations and single-molecule photon antibunching experiments. Execution speed is comparable to the commonly used multiple-tau correlation technique. Wide bin spacings are possible that allow for real-time software calculation of correlations, even for high count rates. (c) 2006 Optical Society of America.