Find the power of b less than and greater than b
A = int ( pow ( b , log_b ) ) NEW_LINE B = int ( pow ( b , log_b + 1 ) ) NEW_LINE if ( ( arr [ i ] - A ) < ( B - arr [ i ] ) ) : NEW_LINE INDENT log_b = A NEW_LINE DEDENT else : NEW_LINE INDENT log_b = B NEW_LINE DEDENT