2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 5900f4451000cf542c50ff57
|
2021-02-06 04:42:36 +00:00
|
|
|
title: 'Problem 216: Investigating the primality of numbers of the form 2n2-1'
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 5
|
2021-02-06 04:42:36 +00:00
|
|
|
forumTopicId: 301858
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: problem-216-investigating-the-primality-of-numbers-of-the-form-2n2-1
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
Consider numbers t(n) of the form t(n) = 2n2-1 with n > 1.
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
The first such numbers are 7, 17, 31, 49, 71, 97, 127 and 161.
|
|
|
|
|
|
|
|
It turns out that only 49 = 7\*7 and 161 = 7\*23 are not prime.
|
|
|
|
|
|
|
|
For n ≤ 10000 there are 2202 numbers t(n) that are prime.
|
|
|
|
|
|
|
|
How many numbers t(n) are prime for n ≤ 50,000,000 ?
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`euler216()` should return 5437849.
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
assert.strictEqual(euler216(), 5437849);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function euler216() {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
euler216();
|
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|