Refactor is_real functionality of factorial