Task: There is a partially broken implementation at /app/starter_code.py. Your job is to fix the bugs and complete the factorial function module so that the project passes all tests.
What to implement
Create or repair a Python module named factorial_example.py at the project root containing a function:
def factorial_function(n) -> int
The function must compute the factorial of a non-negative integer n with the following behavior:
If n is negative, raise AssertionError.
If n is 0, return 1.
If n > 0, return the product 1 * 2 * ... * n (computed iteratively).
Accept only integers; if n is not an int, raise AssertionError.
Do not rely on the standard library’s math.factorial for the actual computation (implement the multiplication loop yourself).
Include a concise docstring describing the function, its input, and its error handling.
Context and constraints
The tests import factorial_function from factorial_example (from factorial_example import factorial_function), so the module must be at the project root as factorial_example.py.
The implementation should align with the tests:
factorial_function(0) == 1
factorial_function(4) == 24
For i in range(5), factorial_function(i) matches math.factorial(i)
factorial_function(-10) raises AssertionError
Acceptance criteria
All tests pass:
test_factorial_functionality: correct results for 0 and 4
test_standard_library: matches math.factorial(i) for i = 0..4
test_negative_number: raises AssertionError for negative input
Code is clean, well-documented, and does not rely on external libraries beyond the standard Python runtime.