2018-09-30 22:01:58 +00:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3e71000cf542c50fefa
|
|
|
|
|
title: 'Problem 123: Prime square remainders'
|
2020-11-27 18:02:05 +00:00
|
|
|
|
challengeType: 5
|
2019-08-05 16:17:33 +00:00
|
|
|
|
forumTopicId: 301750
|
2021-01-13 02:31:00 +00:00
|
|
|
|
dashedName: problem-123-prime-square-remainders
|
2018-09-30 22:01:58 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --description--
|
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
Let $p_n$ be the $n$th prime: 2, 3, 5, 7, 11, ..., and let $r$ be the remainder when ${(p_n−1)}^n + {(p_n+1)}^n$ is divided by ${p_n}^2$.
|
2020-11-27 18:02:05 +00:00
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
For example, when $n = 3, p_3 = 5$, and $4^3 + 6^3 = 280 ≡ 5\\ mod\\ 25$.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
The least value of $n$ for which the remainder first exceeds $10^9$ is 7037.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
Find the least value of $n$ for which the remainder first exceeds $10^{10}$.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --hints--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
`primeSquareRemainders()` should return `21035`.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
```js
|
2021-07-16 19:38:37 +00:00
|
|
|
|
assert.strictEqual(primeSquareRemainders(), 21035);
|
2018-09-30 22:01:58 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --seed--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
## --seed-contents--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
|
|
```js
|
2021-07-16 19:38:37 +00:00
|
|
|
|
function primeSquareRemainders() {
|
2020-09-15 16:57:40 +00:00
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-16 19:38:37 +00:00
|
|
|
|
primeSquareRemainders();
|
2018-09-30 22:01:58 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|