File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- def lucas_number (n : int ) -> int :
1+ def lucas_number (input_index : int ) -> int :
22 """
33 Returns the n-th Lucas number using an iterative approach.
44 The Lucas numbers are an integer sequence where each term is the sum of the
@@ -17,18 +17,18 @@ def lucas_number(n: int) -> int:
1717 >>> lucas_number(-3)
1818 Traceback (most recent call last):
1919 ...
20- ValueError: n must be a non-negative integer.
20+ ValueError: input_index must be a non-negative integer.
2121 """
22- if n < 0 :
23- raise ValueError ("n must be a non-negative integer." )
22+ if input_index < 0 :
23+ raise ValueError ("input_index must be a non-negative integer." )
2424
25- if n == 0 :
25+ if input_index == 0 :
2626 return 2
27- if n == 1 :
27+ if input_index == 1 :
2828 return 1
2929
3030 a , b = 2 , 1
31- for _ in range (2 , n + 1 ):
31+ for _ in range (2 , input_index + 1 ):
3232 a , b = b , a + b
3333 return b
3434
You can’t perform that action at this time.
0 commit comments