Do binary search , for every mid , find sum of binomial coefficients and check if the sum is greater than k or not .
while ( $ low < $ high ) { $ mid = ( $ low + $ high ) / 2 ; if ( binomialCoeff ( $ mid , $ n , $ k ) < $ k ) $ low = $ mid + 1 ; else $ high = $ mid ; } return ( int ) $ low ; }