def Agx_gener(): """ >>> list(islice(Agx_gener(), 20))[-1] 211345365 """ for a, b in skip(g(), 1): if b % 5 == 2: yield (b - 7) / 5
def f(n): """ >>> f(12) 1118049290473932 """ s, index = 0, 0 for a, b in skip(convergent_continued_fraction((2, [4])), 1): if b * b * 5 - a * a == 1: s += b index += 1 if index >= n: return s
def generator(): for b, a in skip(convergent_continued_fraction((1, [2])), 1): if a * a * 2 - b * b == 1: yield (b - 1)/ 2, (b + 1) / 2, a