We will describe a new factorization algorithm based on the reproduction of continuous exponential sums, using the interference pattern produced by polychromatic light interacting with an interferometer with variable optical paths. We will describe two possible interferometers: a generalized symmetric Michelson interferometer and a liquid crystal grating. Such an algorithm allows, for the first time, to find all the factors of a number N in a single run without precalculating the ratio N/l, where l are all the possible trial factors. It also allows to solve the problem of ghost factors and to factorize different numbers using the same output interference pattern.