def factorial(x): if x == 1 or x == 0: return 1 while x > 0: x *= (x - 1) return x
When running factorial(4), I get a result of 12, meaning the loop is stopping at 3. Can anybody tell me why? I've tried one less indent on the return line, but then I get an infinite loop. Tried a break with one less indent on the return and get 12 again. Tried a break with same indention and don't get past factorial(2). Somebody help me here.