Do binary search
let guess = parseInt ( ( low + high ) / 2 , 10 ) ; while ( Math . abs ( ( Math . pow ( guess , n ) ) - x ) >= epsilon ) { if ( Math . pow ( guess , n ) > x ) { high = guess ; } else { low = guess ; } guess = ( low + high ) / 2 ; } document . write ( guess ) ; }