← Complete problem index

PROJECT EULER · #0574

Verifying Primes

Statement only · UnsolvedOriginal problem ↗

Let q be a prime and AB>0 be two integers with the following properties:

  • A and B have no prime factor in common, that is gcd(A,B)=1.
  • The product AB is divisible by every prime less than q.

It can be shown that, given these conditions, any sum A+B<q2 and any difference 1<AB<q2 has to be a prime number. Thus you can verify that a number p is prime by showing that either p=A+B<q2 or p=AB<q2 for some A,B,q fulfilling the conditions listed above.

Let V(p) be the smallest possible value of A in any sum p=A+B and any difference p=AB, that verifies p being prime. Examples:
V(2)=1, since 2=1+1<22.
V(37)=22, since 37=22+15=211+35<72 is the associated sum with the smallest possible A.
V(151)=165 since 151=16514=351127<132 is the associated difference with the smallest possible A.

Let S(n) be the sum of V(p) for all primes p<n. For example, S(10)=10 and S(200)=7177.

Find S(3800).

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.