Example: A deck of **52** (N) cards has **4** (m) red cards. If
we draw **5** (n) cards, what are the odds exactly **1** (k) of them
will be red?

Picking without replacements

- exactly k items is represented in blue,
- less than k items is represented in red, and
- greater than k items is represented in green

Note that we limit input to 1000. This is because when calculating n choose k for inputs of 1000 and 500, we get about 1e300, which is a number larger than should ever been needed, and is just approaching the largest number Javascript will store.

To put this into perspective: Say we take every particle in the known universe and multiply that number by the number of nanoseconds the universe has been alive. This number squared is significantly less than 1e300.

Share Tweet Pin Share Post Post Share Email