You are viewing a single comment's thread. Return to all comments →
def fibonacci(n=0): response = [0, 2] while True: next_num = response[-1] * 4 + response[-2] if next_num > n: return sum(response) response.append(next_num) t = int(input().strip()) for a0 in range(t): n = int(input().strip()) print(fibonacci(n))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
Python 3