Refactored factorial code to avoid duplication of code when addressing cases less than 2