2

In this question it was shown that collections of $8k+1$ odd squares can be found that sum to an odd square. In his answer, Denis Shatrov provided an algorithm by which $8k$ odd numbers $\{a_1,a_2,\dots,a_{8k}\}$ are chosen arbitrarily, and an odd number $a_{8k+1}$ can be derived such that the sum of the squares of the $a_i$ is also an odd square $b^2$, viz: $$N=\sum_{i=1}^{8k}a_i^2$$ $$a_{8k+1}=\left (\frac{N-4}{4}\right )$$ $$b=\left (\frac{N+4}{4}\right )$$ $$b^2=\sum_{i=1}^{8k+1}a_i^2$$ Interestingly, $a_{8k+1}$ and $b$ generated by this algorithm are consecutive odd numbers.

Since the initial $8k$ numbers can be chosen arbitrarily, they can be odd primes (going forward, I will assume that they are distinct odd primes). In that case, can $a_{8k+1}$ and $b$ also be primes? If so, then those generated numbers would be twin primes. A quick empirical survey showed that for $k=1$, it is relatively easy to find collections of $8$ odd squares of primes that give rise to solution in which $a_9$ is a prime, but examples of $b$ being prime were not found.

This observation can be understood by analyzing matters $\bmod 3$. Odd primes other than $3$ have squares $\equiv 1 \bmod 3$. For $k\equiv 1 \bmod 3$, the sum of $8k+1$ odd numbers is either $\equiv 0 \bmod 3$ (when all $a_i \ne 3$) or $\equiv 2 \bmod 3$ (if $a_1 = 3$). In the first case, $b\equiv 0 \bmod 3$ means that $b$ cannot be prime. In the second case, there are no integers $b$ such that $b^2 \equiv 2 \bmod 3$. So when $k\equiv 1 \bmod 3$, it is not possible to find collections of $\{a_i\}$ in which $b$ is the larger member of a pair of twin primes.

Repeating this analysis for $k\equiv 2 \bmod 3$ and $k\equiv 0 \bmod 3$ indicates there is no such absolute barrier to obtaining examples where $b$ is the larger member of a pair of twin primes. In the case $k\equiv 2 \bmod 3$, it is required that $3$ be one of the primes in the initial collection of $a_i$, whereas in the case $k\equiv 0 \bmod 3$, it is required that $3$ not be one of the primes in the initial collection of $a_i$.

My questions are these: Independent of the Shatrov algorithm, is it possible to obtain collections of $8k+1$ distinct odd primes such that the sum of their squares is the square of a prime? Within the Shatrov algorithm, is it possible to obtain collections of $8k+1$ distinct odd primes such that they sum to the square of an odd prime AND $(a_{8k+1},b)$ constitute a twin prime pair?

I realize that the collections of odd prime square summands will have to contain $(17,25,41,49,\dots)$ members, so either theoretical or computational approaches may be challenging.

2 Answers2

8

$$3^2 + 5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 67^2 + 71^2 = 151^2$$

A solution can be found with dynamic programming. In more detail, we can define $f(i, t, c)$ to be true if $t$ is obtainable as a sum of squares of $c$ of the first primes, and then we can find a solution of length $k$ involving the first $n$ primes or confirm one doesn't exists in time $O(k n^3 \log^2(n))$.

$$3^2 + 5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 73^2 + 4649^2 = 4651^2$$

A solution to the second problem can be found in a similar way - choose a pair of twin primes $p, p+2$, and find $k-1$ primes whose squares sum to $4(p+1)$.

sets with 25 primes: $$5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 61^2 + 67^2 + 71^2 + 73^2 + 79^2 + 83^2 + 89^2 + 97^2 + 101^2 + 107^2 + 113^2 = 311^2$$

$$5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 59^2 + 61^2 + 67^2 + 71^2 + 73^2 + 79^2 + 83^2 + 89^2 + 107^2 + 113^2 + 20147^2 = 20149^2$$

41: $$3^2 + 5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 59^2 + 61^2 + 67^2 + 71^2 + 73^2 + 79^2 + 83^2 + 89^2 + 97^2 + 101^2 + 103^2 + 107^2 + 109^2 + 113^2 + 127^2 + 131^2 + 137^2 + 139^2 + 149^2 + 151^2 + 157^2 + 163^2 + 167^2 + 181^2 + 197^2 + 211^2 = 659^2$$

$$3^2 + 5^2 + 7^2 + 11^2 + 13^2 + 17^2 + 19^2 + 23^2 + 29^2 + 31^2 + 37^2 + 41^2 + 43^2 + 47^2 + 53^2 + 59^2 + 61^2 + 67^2 + 71^2 + 73^2 + 79^2 + 83^2 + 89^2 + 97^2 + 101^2 + 103^2 + 107^2 + 109^2 + 113^2 + 127^2 + 131^2 + 137^2 + 139^2 + 149^2 + 151^2 + 157^2 + 167^2 + 173^2 + 179^2 + 181^2 + 96587^2 = 96589^2$$

1

$3^2+3^2+3^2+3^2+3^2+3^2+3^2+3^2+7^2=11^2$.

Please note that this answer was posted when the title was "Can the sum of squares of odd primes equal the square of an odd prime?" and the body ended, "Is it possible to obtain collections of $8k+1$ odd primes such that the sum of their squares is the square of a prime?"

It was easy to miss the clause in the middle, "going forward, I will assume that they are distinct odd primes...."

Gerry Myerson
  • 179,216
  • 2
    I stated in the body of my post that I was interested in distinct primes; I should have made it clear that I was interested in distinct primes in the question as I stated it at the end, and I have edited it to make that clear. However, thanks for this example. – Keith Backman Aug 17 '23 at 14:08