how to optimise my code to make execute in<0.612 sec
actually, i have take a test, online. my program is correct and passed all test cases but unfortunately, i couldn't submit my code. the below program is to find the nearest power of number 'a' and the resultant answer should be less than or equal to 'b' example: 2^3=8 #here, a is 2 and b is 8. the logic is below... def nearestPower(a,b): i=int(0) x=int(1) for x in range(int(b/2)): n=pow(a,x) if(pow(a,x)<=b): rem=int(n) return rem. in output box: your program took more time than expected. Expected time limit<0.612 sec. Hint: please optimise your code.. (my opinion: my code took more time due to range() in for loop.) how to optimise my code: