def f(x,y): a, b = x+y, x-y return (a,b) t = (1,2) d = abs(t[0]-t[1]) while d<=40000: t = f(*t) d = abs(t[0]-t[1]) print(d)