2018-09-30 22:01:58 +00:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3e41000cf542c50fef7
|
|
|
|
|
title: 'Problem 120: Square remainders'
|
2020-11-27 18:02:05 +00:00
|
|
|
|
challengeType: 5
|
2019-08-05 16:17:33 +00:00
|
|
|
|
forumTopicId: 301747
|
2021-01-13 02:31:00 +00:00
|
|
|
|
dashedName: problem-120-square-remainders
|
2018-09-30 22:01:58 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --description--
|
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
|
Let r be the remainder when (a−1)n + (a+1)n is divided by a2.
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
For example, if a = 7 and n = 3, then r = 42: 63 + 83 = 728 ≡ 42 mod 49. And as n varies, so too will r, but for a = 7 it turns out that rmax = 42.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
For 3 ≤ a ≤ 1000, find ∑ rmax.
|
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
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
`euler120()` should return 333082500.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
```js
|
|
|
|
|
assert.strictEqual(euler120(), 333082500);
|
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
|
|
|
|
|
function euler120() {
|
2020-09-15 16:57:40 +00:00
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
euler120();
|
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|