function used to generate binomial coefficient time complexity O ( m )
function binomial_coefficient ( n , m ) { let res = 1 ; if ( m > n - m ) m = n - m ; for ( let i = 0 ; i < m ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; }