2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: 5900f4451000cf542c50ff57
|
|
|
|
title: 'Problem 216: Investigating the primality of numbers of the form 2n2-1'
|
2020-11-27 18:02:05 +00:00
|
|
|
challengeType: 5
|
2019-08-05 16:17:33 +00:00
|
|
|
forumTopicId: 301858
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: problem-216-investigating-the-primality-of-numbers-of-the-form-2n2-1
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --description--
|
|
|
|
|
2021-07-15 07:20:31 +00:00
|
|
|
Consider numbers $t(n)$ of the form $t(n) = 2n^2 - 1$ with $n > 1$.
|
2020-11-27 18:02:05 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
The first such numbers are 7, 17, 31, 49, 71, 97, 127 and 161.
|
|
|
|
|
2021-07-15 07:20:31 +00:00
|
|
|
It turns out that only $49 = 7 \times 7$ and $161 = 7 \times 23$ are not prime.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-15 07:20:31 +00:00
|
|
|
For $n ≤ 10000$ there are 2202 numbers $t(n)$ that are prime.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-15 07:20:31 +00:00
|
|
|
How many numbers $t(n)$ are prime for $n ≤ 50\\,000\\,000$?
|
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-15 07:20:31 +00:00
|
|
|
`primalityOfNumbers()` should return `5437849`.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
```js
|
2021-07-15 07:20:31 +00:00
|
|
|
assert.strictEqual(primalityOfNumbers(), 5437849);
|
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-15 07:20:31 +00:00
|
|
|
function primalityOfNumbers() {
|
2020-09-15 16:57:40 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-15 07:20:31 +00:00
|
|
|
primalityOfNumbers();
|
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
|
|
|
|
```
|