yaworsw/euler-manager

View on GitHub
data/problems/425.yml

Summary

Maintainability
Test Coverage
---
:id: 425
:name: Prime connection
:url: https://projecteuler.net/problem=425
:content: "Two positive numbers A and B are said to be _connected_ (denoted by \"A
  ↔ B\") if one of these conditions holds:  \n(1) A and B have the same length and
  differ in exactly one digit; for example, 123 ↔ 173.  \n(2) Adding one digit to
  the left of A (or B) makes B (or A); for example, 23 ↔ 223 and 123 ↔ 23.\n\nWe 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.\n\nFor example, 127 is a 2's relative.
  One of the possible chains is shown below:  \n2 ↔ 3 ↔ 13 ↔ 113 ↔ 103 ↔ 107 ↔ 127
  \ \nHowever, 11 and 103 are not 2's relatives.\n\nLet F(N) be the sum of the primes
  ≤ N which are not 2's relatives.  \nWe can verify that F(10<sup>3</sup>) = 431 and
  F(10<sup>4</sup>) = 78728.\n\nFind F(10<sup>7</sup>).\n\n"