def calc(limit): a, b = 3, 5 n = 2 d = 1 for i in range(limit): yield n n += d * a a, b = b, a + b a, b = b, a + b d = 3 - d print(sum(list(calc(30))))