Project Euler Problem 365

The binomial coefficient displaystyle{binom{10^{18}}{10^9}} is a number with more than 9 billion (9times 10^9) digits.

Project Euler Problem 365

Solution

Answer: 162619462356610313

After reducing the computation using Lucas’ theorem modulo each prime $p\in(1000,5000)$, evaluating

$$\binom{10^{18}}{10^9}\bmod p$$

for every prime $p$, and then combining residues for each triple $(p,q,r)$ using the Chinese Remainder Theorem over $pqr$, the required sum over all primes $1000<p<q<r<5000$ is:

Answer: 162619462356610313