MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / Fibonacci

Class Fibonacci

dynamic_programming/fibonacci.py:7–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6
7class Fibonacci:
8
9 def __init__(self, N=None):
10 self.fib_array = []
11 if N:
12 N = int(N)
13 self.fib_array.append(0)
14 self.fib_array.append(1)
15 for i in range(2, N + 1):
16 self.fib_array.append(self.fib_array[i - 1] + self.fib_array[i - 2])
17 elif N == 0:
18 self.fib_array.append(0)
19
20 def get(self, sequence_no=None):
21 if sequence_no != None:
22 if sequence_no < len(self.fib_array):
23 return print(self.fib_array[:sequence_no + 1])
24 else:
25 print("Out of bound.")
26 else:
27 print("Please specify a value")
28
29
30if __name__ == '__main__':

Callers 1

fibonacci.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected