Find sum of binomial coefficients xCi ( where i varies from 1 to n ) . If the sum becomes more than K
function binomialCoeff ( x , n , k ) { var sum = 0 , term = 1 ; for ( var i = 1 ; i <= n && sum < k ; ++ i ) { term *= x - i + 1 ; term /= i ; sum += term ; } return sum ; }