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 ] = ( int ) Math . Pow ( x , k ) ; else arr [ i ] = ( int ) Math . Pow ( x , k + 1 ) ;