Refactor .factorial to run independently from .P