I created two methods to generate the fibonacci numbers. The first method is much quicker than the second method.
my_functions.py
#!/usr/bin/env python3
# method 1 def fibonacci(num): num1 = 0 num2 = 1 series = 0 for i in range(num): print(series) num1 = num2 num2 = series series = num1 + num2
# method 2 def fibonacci_reg(number): # return 0 and 1 for first and second terms if number == 0: return 0 elif number == 1: return 1 else: # return the sum of two numbers return fibonacci_reg(number - 1) + fibonacci_reg(number - 2)
fib.py
#!/usr/bin/env python3
from my_functions import * from timeit import default_timer as timer