Last active
June 10, 2021 04:43
-
-
Save dmfed/68ccba16f0087665a98064f118c25a5e to your computer and use it in GitHub Desktop.
Exponent vs polynomial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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