freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-216-investigating-the-primality-of-numbers-of-the-form-2n2-1.english.md
mrugesh 22afc2a0ca feat(learn): python certification projects (#38216)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>
Co-authored-by: Beau Carnes <beaucarnes@gmail.com>
2020-05-27 13:19:08 +05:30

1009 B

id, challengeType, isHidden, title, forumTopicId
id challengeType isHidden title forumTopicId
5900f4451000cf542c50ff57 5 false Problem 216: Investigating the primality of numbers of the form 2n2-1 301858

Description

Consider numbers t(n) of the form t(n) = 2n2-1 with n > 1. 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 ?

Instructions

Tests

tests:
  - text: <code>euler216()</code> should return 5437849.
    testString: assert.strictEqual(euler216(), 5437849);

Challenge Seed

function euler216() {
  // Good luck!
  return true;
}

euler216();

Solution

// solution required