A Monte Carlo factoring algorithm with linear storage