title: How to use 'fn', which generates a function that calculates the golden ratio
body: <p>Using 'fn'  generate function that calculates golden ratio approximation.</p>
  <p>final formula:
  1 + 1 / (1 + 1 / (1 + 1 / (...)))</p>
  <p>some results:</p>
  <pre><code>golden_ratio(0) = 1
  golden_ratio(1) = 2
  golden_ratio(2) = 1.5
  golden_ratio(100) = 1.6180...
  </code></pre>
  <p>Function signature: def golden_ratio (n), where 'n' is number of invocations (and number of terms in continued fraction)</p>
  <p>In general, I did the task, here are the errors:</p>
  <ol>
  <li><p>Function signature: def golden_ratio (n), where 'n' is number of invocations (and number of terms in continued fraction).</p>
  </li>
  <li><p>print (w / q)
  The results are incorrect.</p>
  </li>
  </ol>
  <p>With n = 1000, it displays about 1.62, as it should.</p>
  <pre><code>golden_ratio(0) = 1
  golden_ratio(1) = 2
  golden_ratio(2) = 1.5
  </code></pre>
  <p>but with these n - it does not work.  Help me please(</p>
  <p>this is my code:</p>
  <pre><code>n=1000
  def fn(f,n):
      def wrap(*arg):
          for _ in range(n):
              arg = f(*arg)
          return arg
      return wrap
   
  def fib(q, w):
      q, w = w, q + w
      return q, w
   
  f3 = fn(fib, n)
  q, w = f3(0, 1)
  # gold section
  print(w / q)
  </code></pre>