text: Reduce the number B to a small number using Fermat Little
code: for ( $ i = 0 ; $ i < strlen ( $ b ) ; $ i ++ ) $ remainderB = ( $ remainderB * 10 + $ b [ $ i ] - '0' ) % ( $ MOD - 1 ) ; echo power ( $ a , $ remainderB , $ MOD ) ; ? >