Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Please write me python code to get all Fibonacci numbers until 10 with a recursive…
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Please write me python code to get all Fibonacci numbers until 10 with a recursive function.
- Assistantpython
def _fibonacci_req(tm2=0, tm1=0, max_num=0): """ Function to recursively yield all Fibonacci numbers until max_num :param tm2: number at t-2 :param tm1: number at t-1 :param max_num: maximum number to yield :return: the fibonacci number at t """ if tm1 > max_num: return yield tm1 t = tm1+tm2 if tm1 > 0 else 1 yield from _fibonacci_req(tm1, t, max_num) def fibonacci_numbers(max_num=10): """ Function to get all Fibonacci numbers until max_num (default 10) :param max_num: maximum number of the list :return: """ return [x for x in _fibonacci_req(max_num=max_num)] - User
Thanks. Can you now update it to 15?
- Assistant
Sure, here's the updated python code with the 15 first fibonacci numbers:
pydef _fibonacci_req(tm2=0, tm1=0, max_num=0): """ Function to recursively yield all Fibonacci numbers until max_num :param tm2: number at t-2 :param tm1: number at t-1 :param max_num: maximum number to yield :return: the fibonacci number at t """ if tm1 > max_num: return yield tm1 t = tm1+tm2 if tm1 > 0 else 1 yield from _fibonacci_req(tm1, t, max_num) def fibonacci_numbers(max_num=15): """ Function to get all Fibonacci numbers until max_num (default 15) :param max_num: maximum number of the list :return: """ return [x for x in _fibonacci_req(max_num=max_num)]
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)