Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions fibonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def fibonacci(n: int) -> list[int]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: n

"""
Return first n Fibonacci numbers.
Example:
>>> fibonacci(5)
[0, 1, 1, 2, 3]
"""
if n <= 0:
return []
fib_seq = [0, 1]
for i in range(2, n):
fib_seq.append(fib_seq[i - 1] + fib_seq[i - 2])
return fib_seq[:n]
Loading