Maths Olympiad Prep

Track / Stage 5 / 179 of 400 #1259 of 2444

Problem 1259

AIME late
Number theory Difficulty 5.3 Find the answer HMMT February · United States

A prime number pp is twin if at least one of p+2p+2 or p2p-2 is prime and sexy if at least one of p+6p+6 and p6p-6 is prime.
How many sexy twin primes (i.e. primes that are both twin and sexy) are there less than 10910^{9}? Express your answer as a positive integer NN in decimal notation; for example, 521495223. If your answer is in this form, your score for this problem will be max{0,25110000AN}\max \left\{0,25-\left\lfloor\frac{1}{10000}|A-N|\right\rfloor\right\}, where AA is the actual answer to this problem. Otherwise, your score will be zero.

A number or a short expression. Fractions can be typed as 3/2, and spacing doesn't matter.

Next problem →

Official solution

Solution:

Answer: 1462105

The Hardy-Littlewood conjecture states that given a set AA of integers, the number of integers xx such that x+ax+a is a prime for all aAa \in A is
x(lnx)Ap1w(p;A)p(11p)k(1+o(1)) \frac{x}{(\ln x)^{|A|}} \prod_{p} \frac{1-\frac{w(p ; A)}{p}}{\left(1-\frac{1}{p}\right)^{k}}(1+o(1))
where w(p;A)w(p ; A) is the number of distinct residues of AA modulo pp and the o(1)o(1) term goes to 0 as xx goes to infinity. Note that for the 4 tuples of the form (0,±2,±6)(0, \pm 2, \pm 6), w(p;A)=3w(p ; A)=3, and using the approximation 1k/p(11/p)k1(k2)/p2(11p2)(k2)\frac{1-k / p}{(1-1 / p)^{k}} \approx 1-\binom{k}{2} / p^{2} \approx\left(1-\frac{1}{p^{2}}\right)^{\binom{k}{2}}, we have
p>31kp(11p)k(6π2)(k2)(43)(k2)(98)(k2)(910)(k2) \prod_{p>3} \frac{1-\frac{k}{p}}{\left(1-\frac{1}{p}\right)^{k}} \approx\left(\frac{6}{\pi^{2}}\right)^{\binom{k}{2}} \cdot\left(\frac{4}{3}\right)^{\binom{k}{2}}\left(\frac{9}{8}\right)^{\binom{k}{2}} \approx\left(\frac{9}{10}\right)^{\binom{k}{2}}
Applying this for the four sets A=(0,±2,±6)A=(0, \pm 2, \pm 6), x=109x=10^{9} (and approximating lnx=20\ln x=20 and just taking the p=2p=2 and p=3p=3 terms), we get the approximate answer
4109203112(12)3123(13)3(910)3=1640250 4 \cdot \frac{10^{9}}{20^{3}} \frac{1-\frac{1}{2}}{\left(\frac{1}{2}\right)^{3}} \frac{1-\frac{2}{3}}{\left(\frac{1}{3}\right)^{3}}\left(\frac{9}{10}\right)^{3}=1640250
One improvement we can make is to remove the double-counted tuples, in particular, integers xx such that x,x+6,x6x, x+6, x-6, and one of x±2x \pm 2 is prime. Again by the Hardy-Littlewood conjecture, the number of such xx is approximately (using the same approximations)
2109204112(12)4123(13)4(910)690000 2 \cdot \frac{10^{9}}{20^{4}} \frac{1-\frac{1}{2}}{\left(\frac{1}{2}\right)^{4}} \frac{1-\frac{2}{3}}{\left(\frac{1}{3}\right)^{4}}\left(\frac{9}{10}\right)^{6} \approx 90000
Subtracting gives an estimate of about 1550000. Note that this is still an overestimate, as ln109\ln 10^{9} is actually about 20.7 and 1k/p(11/p)k<(11p2)(k2)\frac{1-k / p}{(1-1 / p)^{k}}<\left(1-\frac{1}{p^{2}}\right)^{\binom{k}{2}}.

Here is the C++\mathrm{C}++ code that we used to generate the answer:

```
#include<iostream>
#include<cstring> // memset
using namespace std;
const int MAXN = 1e9;
bool is_prime[MAXN + 6];
int main(){
// Sieve of Eratosthenes
memset(is_prime, true, sizeof(is_prime));
is_prime[0] = is_prime[1] = false;
for (int i=2; i<MAXN + 6; i++){
if (is_prime*){
for (int j=2 * i; j < MAXN + 6; j += i){
is_prime[j] = false;
}
}
}
// Count twin sexy primes.
int ans = 1; // 5 is the only twin sexy prime < 6.
for (int i=6; i<MAXN; i++){
if (is_prime*
&& (is_prime[i-6] || is_prime[i+6])
&& (is_prime[i-2] || is_prime[i+2])) {
ans++;
}
}
cout << ans << endl;
return 0;
}
```

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty, ordering) added by this project.