solution got wrong answer, add a case for factorial(0) which wasn't handled before