Find the power of a less than and greater than a
let A = Math . floor ( Math . pow ( a , log_a ) ) ; let B = Math . floor ( Math . pow ( a , log_a + 1 ) ) ; if ( ( arr [ i ] - A ) < ( B - arr [ i ] ) ) log_a = A ; else log_a = B ;