from fractions import Fraction as f a=[f(1,2)] for k in range(1,1000):a.append(f(1,2+a[-1])) print sum(len(str((1+a[k]).numerator))>len(str((1+a[k]).denominator)) for k in range(1000))