Write me a Python function computing the fibonacci numbers. The function should be…
- User
Write me a Python function computing the fibonacci numbers. The function should be faulty, but almost correct. Also write a unit test which tests whether the algorithm is correct, and the unit test needs to fail.
- Assistant
Here's a faulty Python function that computes Fibonacci numbers along with a unit test that fails:
pythondef fibonacci(n): if n <= 0: return 0 elif n == 1: return 1 else: return fibonacci(n - 1) + fibonacci(n - 2) + 1 # Faulty line: adding an extra 1
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.