Retype This Passage
Python Function for Fibonacci Sequence
A concise Python function that returns the nth Fibonacci number using an iterative approach.
90s testintermediateCode passage
Instructions
Type the code exactly as shown, preserving indentation, colons, parentheses, and line breaks.
Timer01:30
WPM0
Accuracy100%
Progress0%
Mistakes0
python-fibonacci-function
def fibonacci(n: int) -> int:↵
"""Return the n‑th Fibonacci number (0‑indexed)."""↵
if n < 0:↵
raise ValueError("n must be a non‑negative integer")↵
a, b = 0, 1↵
# iterate n times↵
for _ in range(n):↵
a, b = b, a + b↵
return a
def fibonacci(n: int) -> int:↵
"""Return the n‑th Fibonacci number (0‑indexed)."""↵
if n < 0:↵
raise ValueError("n must be a non‑negative integer")↵
a, b = 0, 1↵
# iterate n times↵
for _ in range(n):↵
a, b = b, a + b↵
return a
The passage stays in place while your typed text lines up directly on top of it. Tip: use `Tab` for `⇄` and `Enter` for `↵` while typing the passage.
Correct chars: 0Typed chars: 0Mistakes: 0Status: Ready