my code is 80% right but there are 2 tests I cant pass.
here is my code
import math
def fib(n):
a,b = 1,1
for i in range(n-1):
a,b = b,a+b
return a
is right when I test fib(100)
but there are one more requirement is time. so here is my test
# this should run in less than 5 seconds
print(fib(10 ** 6) % 10 ** 10)
is should under 5 second but my code speed like 10sec to run it.
# this should run in less than 10 seconds
print(math.floor(math.log10(fib ( 5 * 10 ** 6 ))))
so how to improve my code to run these two tests under 10 seconds.
any suggestion will be glad :)