Project Euler problem #25
#python program with test cases to find the index of 1000 digits fibonacci number
import unittest
def fib_index(n):
if type(n)!=int:
return 'Type error'
if n<1 :
return None
count=2
length=1
a,b=1,1
while length!=n:
c=a+b
a=b
b=c
count+=1
length=len(str(b))
return count
print(fib_index(1000))
class test_cases(unittest.TestCase):
def test_fib_index(self):
self.assertEqual(fib_index(-10),None)
self.assertEqual(fib_index('456'), 'Type error')
self.assertEqual(fib_index(3),12)
if __name__ == "__main__":
unittest.main()