2D array to store value of combinations nCr
let C = new Array ( max ) ; for ( let i = 0 ; i < max ; i ++ ) { C [ i ] = new Array ( max ) ; for ( let j = 0 ; j < max ; j ++ ) { C [ i ] [ j ] = 0 ; } } function power ( x , y ) { let res = 1 ; x = x % MOD ; while ( y > 0 ) { if ( y % 2 == 1 ) { res = ( res * x ) % MOD ; } y = y >> 1 ; x = ( x * x ) % MOD ; } return res % MOD ; }