"# [Goldbach's Other Conjecture](https://projecteuler.net/problem=46)\n",
"\n",
"We can write a function that takes odd composites $m$ and checks successively larger values of $n$ to see if $m - 2n^2$ is prime. If we find such an $n$, $m$ satisfies the conjecture, but if $n$ gets too large, $m - 2n^2$ will become non-positive, and therefore can't be prime, so $m$ fails to satisfy the conjecture."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "eba09d52",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5777"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from itertools import count\n",
"\n",
"def satisfies_conjecture(m):\n",
" for n in count(1):\n",
" p = m - 2 * n^2\n",
" if p <= 0:\n",
" return False\n",
" \n",
" if is_prime(p):\n",
" return True\n",
"\n",
"\n",
"for k in count(2):\n",
" m = 2 * k - 1\n",
" if is_prime(m):\n",
" continue\n",
" \n",
" if not satisfies_conjecture(m):\n",
" break\n",
"\n",
"m"
]
},
{
"cell_type": "markdown",
"id": "dd35bb73",
"metadata": {},
"source": [
"Interestingly, the only other number known not to satisfy this conjecture is 5993."
"* Stern numbers (includes all odd numbers, not just composites): [A060003](https://oeis.org/A060003)\n",
"\n",
"#### Copyright (C) 2025 filifa\n",
"\n",
"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)."