"An easy way to approach this problem is to first find [arithmetic progressions of primes](https://en.wikipedia.org/wiki/Primes_in_arithmetic_progression), then check if any of those progressions have numbers that are permutations of each other.\n",
"\n",
"To start, we'll generate all the four-digit primes."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d278b9e4",
"metadata": {},
"outputs": [],
"source": [
"primes = prime_range(1000, 10000)"
]
},
{
"cell_type": "markdown",
"id": "97dab665",
"metadata": {},
"source": [
"Here's where we find arithmetic progressions. Given two primes $p < q$, we can calculate their difference $d = q - p$ and check if $q + d$ is prime - if it is, we have a three-number progression."
"This work is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0/) and the [BSD Zero Clause license](https://spdx.org/licenses/0BSD.html)."