Smipple is shutting down Nov 30, 2017. Some features are currently disabled.
Profile image for Thomas Simonsen simoth00
Fibonacci
Language
Python
Tags
Fibonacci

Fibonacci

1 from timeit import Timer 2 from fibo import fib 3 4 t1 = Timer("fib(10)","from fibo import fib") 5 6 for i in range(1,41): 7 s = "fib(" + str(i) + ")" 8 t1 = Timer(s,"from fibo import fib") 9 time1 = t1.timeit(3) 10 s = "fibi(" + str(i) + ")" 11 t2 = Timer(s,"from fibo import fibi") 12 time2 = t2.timeit(3) 13 print("n=%2d, fib: %8.6f, fibi: %7.6f, percent: %10.2f" % (i, time1, time2, time1/time2))

Comments