title: Project Euler #25: Keep getting Overflow error (result to large) - is it to do with calculating fibonacci number?
body: <p>I'm working on solving the Project Euler problem 25:</p>
  
  <blockquote>
    <p>What is the first term in the Fibonacci sequence to contain 1000
    digits?</p>
  </blockquote>
  
  <p>My piece of code works for smaller digits, but when I try a 1000 digits, i get the error: </p>
  
  <p><code>OverflowError: (34, 'Result too large')</code></p>
  
  <p>I'm thinking it may be on how I compute the fibonacci numbers, but i've tried several different methods, yet i get the same error.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>'''
   What is the first term in the Fibonacci sequence to contain 1000 digits
  '''
  
  def fibonacci(n):
      phi = (1 + pow(5, 0.5))/2           #Golden Ratio
      return int((pow(phi, n) - pow(-phi, -n))/pow(5, 0.5))   #Formula: http://bit.ly/qDumIg
  
  
  n = 0
  while len(str(fibonacci(n))) &lt; 1000:
      n += 1
  print n
  </code></pre>
  
  <p>Do you know what may the cause of this problem and how i could alter my code avoid this problem?</p>
  
  <p>Thanks in advance.</p>