Math, asked by Abubakar6640, 1 year ago

You are given two numbers a and b. When a is raised to some power p, we get a number x. Now, you need to find what is the value of x that is closest to b.

Answers

Answered by sayantanpalkolp6wqi5
19

Answer:

def nearestPower(a,b):

   x=math.floor(math.log(b,a))

   xPlusOne=x+1

   number1=a**x

   number2=a**xPlusOne

   if(abs(number1-b)>abs(number2-b)):

       return number2

   else:

       return number1

Step-by-step explanation:

Similar questions