Created
November 20, 2017 06:22
-
-
Save sakekasi/7c181fa1e3d05067a7899420100efe57 to your computer and use it in GitHub Desktop.
Closest Power Problem Description
This file contains 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 closest_power(base, num): | |
''' | |
base: base of the exponential, integer > 1 | |
num: number you want to be closest to, integer > 0 | |
Find the integer exponent such that base**exponent is closest to num. | |
Note that the base**exponent may be either greater or smaller than num. | |
In case of a tie, return the smaller value. | |
Returns the exponent. | |
''' | |
# your code goes here | |
pass | |
example1 = closest_power(3, 12) # should return 2 | |
example2 = closest_power(4, 12) # should return 2 | |
example3 = closest_power(4, 1) # should return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment