Try it!
You may need to wait or refresh to let it load
Description
View the source code
import time
def timer(func):
def wrapper(*args, **kwargs):
start = time.time()
result = func(*args,**kwargs)
end = time.time()
print(f"{func.__name__} took {end-start} seconds")
return result
return wrapper
@timer
def factorial(num):
if num == 0:
return 0
elif num == 1:
return 1
return factorial(num-1)+factorial(num-2)
print(factorial(3))
Previous Day
Next Day