Implement factorial.