Open the context
Choose the project folder and name the files or behavior involved.
Calculate exact binomial coefficients for integer n from zero to 10000 and integer k from zero to n. Check both endpoints, symmetry and a large result, rejecting invalid or Boolean operands before entering the product loop.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def binomial(n, k):
if any(type(v) is not int for v in (n, k)):
raise ValueError("integer.required")
if not 0 <= k <= n <= 10000:
raise ValueError("binomial.range")
k = min(k, n - k)
result = 1
for i in range(1, k + 1):
result = result * (n - k + i) // i
return resultThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.