2018-09-30 23:01:58 +01:00
|
|
|
|
---
|
|
|
|
|
id: 5900f4da1000cf542c50ffec
|
|
|
|
|
title: 'Problem 365: A huge binomial coefficient'
|
2020-11-27 19:02:05 +01:00
|
|
|
|
challengeType: 5
|
2019-08-05 09:17:33 -07:00
|
|
|
|
forumTopicId: 302026
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: problem-365-a-huge-binomial-coefficient
|
2018-09-30 23:01:58 +01:00
|
|
|
|
---
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --description--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 21:48:17 +02:00
|
|
|
|
The binomial coefficient $\displaystyle\binom{{10}^{18}}{{10}^9}$ is a number with more than 9 billion ($9 × {10}^9$) digits.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 21:48:17 +02:00
|
|
|
|
Let $M(n, k, m)$ denote the binomial coefficient $\displaystyle\binom{n}{k}$ modulo $m$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 21:48:17 +02:00
|
|
|
|
Calculate $\sum M({10}^{18}, {10}^9, p \times q \times r)$ for $1000 < p < q < r < 5000$ and $p$, $q$, $r$ prime.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --hints--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 21:48:17 +02:00
|
|
|
|
`hugeBinomialCoefficient()` should return `162619462356610300`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
```js
|
2021-07-29 21:48:17 +02:00
|
|
|
|
assert.strictEqual(hugeBinomialCoefficient(), 162619462356610300);
|
2018-09-30 23:01:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --seed--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
## --seed-contents--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
|
|
```js
|
2021-07-29 21:48:17 +02:00
|
|
|
|
function hugeBinomialCoefficient() {
|
2020-09-15 09:57:40 -07:00
|
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-29 21:48:17 +02:00
|
|
|
|
hugeBinomialCoefficient();
|
2018-09-30 23:01:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --solutions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|