Implementing large instances of quantum algorithms1–5 requires the processing of many quantum information carriers in a hardware platform that supports the integration of different components6. Although established semiconductor fabrication processes can integrate many photonic components7, the generation and algorithmic processing of many photons has been a bottleneck in integrated photonics. Here, we report the on-chip generation and algorithmic processing of quantum states of light with up to eight photons. Switching between different optical pumping regimes, we implement the scattershot8,9, Gaussian10 and standard boson sampling3,11–14 protocols in the same silicon chip, which integrates linear and nonlinear photonic circuitry. We use these results to benchmark a quantum algorithm for calculating molecular vibronic spectra4. Our techniques can be readily scaled for the on-chip implementation of specialized quantum algorithms with tens of photons, pointing the way to efficiency advantages over conventional computers15.