import itertools
from fractions import Fraction
def series(u0=Fraction(3, 2), u1=Fraction(5, 3)):
yield u0
yield u1
while u0 != u1:
un = 2003 - 6002/u1 + 4000/(u1*u0)
yield un
u1, u0 = un, u1
for i, u in enumerate(itertools.islice(series(), 100)):
err = (2-u)/2 # relative error
print("%d\t%.2g" % (i, err))
aW1wb3J0IGl0ZXJ0b29scwpmcm9tIGZyYWN0aW9ucyBpbXBvcnQgRnJhY3Rpb24KCmRlZiBzZXJpZXModTA9RnJhY3Rpb24oMywgMiksIHUxPUZyYWN0aW9uKDUsIDMpKToKICAgIHlpZWxkIHUwCiAgICB5aWVsZCB1MQogICAgd2hpbGUgdTAgIT0gdTE6CiAgICAgICAgdW4gPSAyMDAzIC0gNjAwMi91MSArIDQwMDAvKHUxKnUwKQogICAgICAgIHlpZWxkIHVuCiAgICAgICAgdTEsIHUwID0gdW4sIHUxCgpmb3IgaSwgdSBpbiBlbnVtZXJhdGUoaXRlcnRvb2xzLmlzbGljZShzZXJpZXMoKSwgMTAwKSk6CiAgICBlcnIgPSAoMi11KS8yICMgcmVsYXRpdmUgZXJyb3IKICAgIHByaW50KCIlZFx0JS4yZyIgJSAoaSwgZXJyKSkK