Two lessons: The accumulator pattern (starting with a value and updating it in a loop) works inside functions too.
Edge cases matter. Factorial of should return . The loop handles this naturally because range(1, 1) is empty. Always test your functions with edge cases: , , negative numbers, empty inputs. They reveal bugs.