title: One test case fails due to runtime error
body: <p>I was trying Project Euler <a href="https://www.hackerrank.com/contests/projecteuler/challenges/euler025" rel="nofollow noreferrer">problem 25</a> on HackerRank.</p>
  
  <p>I attempted a brute force method using Binet's <a href="http://mathworld.wolfram.com/BinetsFibonacciNumberFormula.html" rel="nofollow noreferrer">Formula</a>.</p>
  
  <pre><code>import math
  
  for _ in range(int(input())):
      numLen = int(input())
      for x in range(1, 5000):
          fib = 1/pow(5,.5)*(pow(((1+pow(5,.5))/2),x) - pow(((1-pow(5,.5))/2),x))
          if(numLen == len(str(int(fib)))):
              print(x)
              break
  </code></pre>
  
  <p>Here 5000 is an arbitrary number based on the assumption input is not more than that and the problem is not here as its a runtime error which I'm think is because it's exceeding integer range(not sure).</p>
  
  <p>It also calculates other test cases in less than 0.25 seconds.</p>
  
  <p>I did some searching and found <a href="https://stackoverflow.com/questions/20808763/non-brute-force-solution-to-project-euler-25">this</a>.</p>
  
  <p>but by that recurrence method:</p>
  
  <pre><code>import math
  
  for _ in range(int(input())):
      a = 1
      b = 0
      n = int(input())
      term = 1
      while len(str(a)) != n:
          a, b = a+b, a
          term+=1
      print (term) 
  </code></pre>
  
  <p>gives a timeout as it exceeds 10 seconds.</p>
  
  <p>Can you please help me find a way to improve the first method and optimize the second method.</p>
  
  <p>Note: I tried storing the pow() values in variables instead of recomputing and was of not much help.</p>