Iterative Function to calculate base ^ pow in O ( log y )
function power ( base , pow ) { let res = 1 ; while ( pow > 0 ) { if ( ( pow & 1 ) == 1 ) res = ( res * base ) ; base = ( base * base ) ; pow >>= 1 ; } return res ; }