x = [1] y = [0] for i in range(50): nx = 4 * x[-1] - y[-1] ny = x[-1] x.append(nx) y.append(ny) v, w = 0, 0 for i in range(51): if x[i] < 10 ** 9 and y[i] < 10 ** 9: v, w = x[i], y[i] print(v, w)