def fibrepr(n):
    fibs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
    def fib_iter(n, fibs, l):
        for i, f in enumerate(fibs):
            if f == n:
                yield '1' + i*'0' + l
            elif n > f:
                for fib in fib_iter(n - f, fibs[i+1:], '1' + i*'0' + l):
                    yield fib
            else:
                break
    return fib_iter(n, fibs, '')

class Fibonacci(object):
    _cache = {0: 1, 1: 2}

    def __init__(self, n):
        self.n = n

    def get(self, n):
        if not n in Fibonacci._cache:
            Fibonacci._cache[n] = self.get(n-1) + self.get(n-2)
        return Fibonacci._cache[n]

    def next(self):
        return Fibonacci(self.n + 1)

    def __iter__(self):
        while True:
            yield self.get(self.n)
            self.n += 1


def fibrepr(n):
    def fib_iter(n, fib, l):
        for i, f in enumerate(fib):
            if f == n:
                yield '1' + i*'0' + l
            elif n > f:
                for match in fib_iter(n - f, fib.next(), '1' + i*'0' + l):
                    yield match
            else:
                break
    return fib_iter(n, Fibonacci(0), '')

Add Fibonacci class and use it in representation
Add Fibonacci class and use it in representation

+ class Fibonacci(object):
+     _cache = {0: 1, 1: 2}
+ 
+     def __init__(self, n):
+         self.n = n
+ 
+     def get(self, n):
+         if not n in Fibonacci._cache:
+             Fibonacci._cache[n] = self.get(n-1) + self.get(n-2)
+         return Fibonacci._cache[n]
+ 
+     def next(self):
+         return Fibonacci(self.n + 1)
+ 
+     def __iter__(self):
+         while True:
+             yield self.get(self.n)
+             self.n += 1
+ 
+ 
  def fibrepr(n):
-     fibs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
-     def fib_iter(n, fibs, l):
+     def fib_iter(n, fib, l):
-         for i, f in enumerate(fibs):
+         for i, f in enumerate(fib):
              if f == n:
                  yield '1' + i*'0' + l
              elif n > f:
-                 for fib in fib_iter(n - f, fibs[i+1:], '1' + i*'0' + l):
+                 for match in fib_iter(n - f, fib.next(), '1' + i*'0' + l):
-                     yield fib
+                     yield match
              else:
                  break
-     return fib_iter(n, fibs, '')
+     return fib_iter(n, Fibonacci(0), '')
  
Add Fibonacci class and use it in representation
## Code Before:
def fibrepr(n):
    fibs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
    def fib_iter(n, fibs, l):
        for i, f in enumerate(fibs):
            if f == n:
                yield '1' + i*'0' + l
            elif n > f:
                for fib in fib_iter(n - f, fibs[i+1:], '1' + i*'0' + l):
                    yield fib
            else:
                break
    return fib_iter(n, fibs, '')

## Instruction:
Add Fibonacci class and use it in representation
## Code After:
class Fibonacci(object):
    _cache = {0: 1, 1: 2}

    def __init__(self, n):
        self.n = n

    def get(self, n):
        if not n in Fibonacci._cache:
            Fibonacci._cache[n] = self.get(n-1) + self.get(n-2)
        return Fibonacci._cache[n]

    def next(self):
        return Fibonacci(self.n + 1)

    def __iter__(self):
        while True:
            yield self.get(self.n)
            self.n += 1


def fibrepr(n):
    def fib_iter(n, fib, l):
        for i, f in enumerate(fib):
            if f == n:
                yield '1' + i*'0' + l
            elif n > f:
                for match in fib_iter(n - f, fib.next(), '1' + i*'0' + l):
                    yield match
            else:
                break
    return fib_iter(n, Fibonacci(0), '')
