Example #1
0
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
Example #2
0
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