factorfn for encapsulating large factor computations.