Skip to content

Instantly share code, notes, and snippets.

@dmfed
Last active June 10, 2021 04:43
Show Gist options
  • Save dmfed/68ccba16f0087665a98064f118c25a5e to your computer and use it in GitHub Desktop.
Save dmfed/68ccba16f0087665a98064f118c25a5e to your computer and use it in GitHub Desktop.
Exponent vs polynomial
def get_exponent_func(k):
def exponent(n):
return k ** n
return exponent
def get_poly_func(k):
def poly(n):
return n ** k
return poly
polyn = get_poly_func(2)
expon = get_exponent_func(1.01)
for i in range(1,101):
print(f'polynomial: {polyn(i)}\nexponent: {expon(i)}')
## BUT!
i = 2
while True:
if expon(i) > polyn(i):
print(f'Exponent wins at i = {i}')
break
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment