Skip to content

Instantly share code, notes, and snippets.

@sakekasi
Created November 20, 2017 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakekasi/7c181fa1e3d05067a7899420100efe57 to your computer and use it in GitHub Desktop.
Save sakekasi/7c181fa1e3d05067a7899420100efe57 to your computer and use it in GitHub Desktop.
Closest Power Problem Description
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