1.2 KiB
1.2 KiB
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5900f5151000cf542c510028 | Problem 425: Prime connection | 5 | 302095 | problem-425-prime-connection |
--description--
Two positive numbers A
and B
are said to be connected (denoted by "A ↔ B
") if one of these conditions holds:
A
andB
have the same length and differ in exactly one digit; for example,123 ↔ 173
.- Adding one digit to the left of
A
(orB
) makesB
(orA
); for example,23 ↔ 223
and123 ↔ 23
.
We call a prime P
a 2's relative if there exists a chain of connected primes between 2 and P
and no prime in the chain exceeds P
.
For example, 127 is a 2's relative. One of the possible chains is shown below:
2 ↔ 3 ↔ 13 ↔ 113 ↔ 103 ↔ 107 ↔ 127
However, 11 and 103 are not 2's relatives.
Let F(N)
be the sum of the primes ≤ N
which are not 2's relatives. We can verify that F({10}^3) = 431
and F({10}^4) = 78\\,728
.
Find F({10}^7)
.
--hints--
primeConnection()
should return 46479497324
.
assert.strictEqual(primeConnection(), 46479497324);
--seed--
--seed-contents--
function primeConnection() {
return true;
}
primeConnection();
--solutions--
// solution required