Skip to content

Commit 1fca966

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d4d94d4 commit 1fca966

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

maths/leonardo_numbers.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
def leonardo_numbers(n: int) -> int:
22
"""
33
Return the n-th Leonardo number.
4-
4+
55
The Leonardo numbers are a sequence of numbers given by the recurrence:
66
L(n) = L(n-1) + L(n-2) + 1
77
with initial values L(0) = 1 and L(1) = 1.
8-
8+
99
Reference: https://en.wikipedia.org/wiki/Leonardo_number
10-
10+
1111
>>> leonardo_numbers(0)
1212
1
1313
>>> leonardo_numbers(1)
@@ -31,16 +31,18 @@ def leonardo_numbers(n: int) -> int:
3131
"""
3232
if not isinstance(n, int) or n < 0:
3333
raise ValueError("n must be a non-negative integer")
34-
34+
3535
if n == 0 or n == 1:
3636
return 1
37-
37+
3838
a, b = 1, 1
3939
for _ in range(n - 1):
4040
a, b = b, a + b + 1
41-
41+
4242
return b
4343

44+
4445
if __name__ == "__main__":
4546
import doctest
46-
doctest.testmod()
47+
48+
doctest.testmod()

0 commit comments

Comments
 (0)