Coverage for src/sandbox/fibonacci.py: 100%
11 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-01 21:36 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-01 21:36 +0000
1from typing import List
4class Fibonacci:
5 """Fibonacci sequence methods."""
7 @staticmethod
8 def calculate(nth: int) -> int:
9 """Calculate the n-th Fibonacci number.
11 An extended description of Fibonacci numbers can go here.
13 Parameters
14 ----------
15 nth
16 Number of Fibonacci sequence to calculate.
18 Returns
19 -------
20 int
21 Value of n-th Fibonacci number.
22 """
24 num_a, num_b = 0, 1
26 for _ in range(nth):
27 num_a, num_b = num_b, num_a + num_b
29 return num_a
31 @staticmethod
32 def get_values(nth: int) -> List:
33 """Returns the Fibonacci sequence up until n-th number.
35 Parameters
36 ----------
37 nth
38 Number of Fibonacci sequence to calculate.
40 Returns
41 -------
42 list
43 Fibonacci numbers.
44 """
46 return [Fibonacci.calculate(i) for i in range(1, nth + 1)]