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
Sure! Here's a function that computes the Fibonacci numbers using the naive approach, which is to recursively call itself with smaller inputs:
def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.