R: How can I calculate large numbers in n-choose-k? [duplicate]
问题 This question already has answers here : How would you program Pascal's triangle in R? (2 answers) How to work with large numbers in R? (1 answer) Closed 3 years ago . For a class assignment, I need to create a function that calculates n Choose k. I did just that, and it works fine with small numbers (e.g. 6 choose 2), but I'm supposed to get it work with 200 choose 50, where it naturally doesn't. The answer is too large and R outputs NaN or Inf, saying: > q5(200, 50) [1] "NaN" Warning