Пример #1
0
    def test0002(self):
        from id_0002 import fib, fib_iter
        import itertools

        # f = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
        f = list(itertools.islice(fib_iter(), 100))[2:]
        for i, v in enumerate(f):
            self.assertEqual(fib(i + 1), v)
Пример #2
0
def fib_n_digits(n):
    i = 0
    f = fib_iter()
    while True:
        p = f.next()
        if p/(10**(n - 1)) >= 1:
            break
        i += 1
    return i