Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def exec_time(func):
- def inner(*args, **kwargs):
- import time
- st = time.time()
- ret = func(*args, **kwargs)
- et = time.time() - st
- print "execution time %s seconds" %(et)
- return ret
- return inner
- @exec_time
- def fabonacci(n):
- if n == 0:
- return 0
- elif n == 1:
- return 1
- a, b = 0, 1
- i = 2
- while i < n:
- a, b = b, a + b
- i += 1
- return b
- if __name__ == "__main__":
- print fabonacci(20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement