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