Returns modulo exponentiation for two numbers represented as long long let . It is used by powerStrings ( ) . Its complexity is log ( n )
function powerLL ( x , n ) { let result = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) { result = result * x % MOD ; } n = Math . floor ( n / 2 ) ; x = x * x % MOD ; } return result ; }