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.