try: from common.inputChecking.typeCheck import inputTypeCheck except ModuleNotFoundError: print('Sjekk README.md for hvilke flagg python trenger') exit(1) def fibonacciIterative(n): k1 = 0 k2 = 1 for i in range(n - 1): previousK2 = k2 k2 = k1 + k2 k1 = previousK2 return k1 fibonacciSum = lambda n: sum([fibonacciIterative(i) for i in range(1, n + 1)]) fibonacciList = lambda n: [fibonacciIterative(i) for i in range(1, n + 1)] if __name__ == "__main__": n = inputTypeCheck('n: ', int) print(f'a) Fibonacci({n})', fibonacciIterative(n)) print(f'b) Sum av Fibonacci(1..{n})', fibonacciSum(n)) print(f'c) Sum av Fibonacci(1..{n})', fibonacciList(n))