Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th…
- User
Write a program which prints -th fibonacci number for a given integer . The -th fibonacci number is defined by the following recursive formula:
\begin{equation*} fib(n)= \left \{ \begin{array}{ll} 1 & (n = 0) \\ 1 & (n = 1) \\ fib(n - 1) + fib(n - 2) & \\ \end{array} \right. \end{equation*}
Constraints
- Input
An integer is given.
Assistant
pythonn = int(input()) if n <= 1: print(1) else: a, b = 1, 1 for i in range(2, n + 1): a, b = b, a + b print(b)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.