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