Find the power to x nearest to arr [ i ]
if ( Math . abs ( Math . pow ( x , k ) - arr [ i ] ) < Math . abs ( Math . pow ( x , k + 1 ) - arr [ i ] ) ) arr [ i ] = Math . pow ( x , k ) ; else arr [ i ] = Math . pow ( x , k + 1 ) ;