# Can any odd positive integer greater than $3$ be expressed as the sum of $2$ perfect square numbers (excluding $0$) plus $1$ prime number?

I have been reading about the "odd Goldbach conjecture" which states that:

Every odd integer greater than $$7$$ can be written as the sum of three odd primes

I have also been reading about the fact that for large $$𝑁$$ there are considerably more primes than perfect squares numbers.

At first I have tried to run an experiment and see if any odd number can be written as the sum of one perfect square and one prime number, and although most attempts (in the beginning) were true, some others where false.

So since the "odd Goldbach conjecture" involves three different numbers, I have allowed myself to check if any odd number can be written as the sum of $$2$$ perfect squares and $$1$$ prime number.

I have manually checked it for the first few hundreds' results, and so far I have found no counter example for any odd positive integers greater than $$3$$

A prime number (greater than $$3$$) can be written as $$6n+1$$ or $$6n-1$$ and a perfect square number can be written as $$4n$$ or $$4n + 1$$.

Also, even though perfect squares are more rare than prime numbers, unlike prime numbers, perfect squares have $$1$$ at their disposal ($$1^1 = 1$$), and unfortunately for primes $$1$$ is not a prime number.

So my question is:

If there are any counter examples or any proofs? and if not what is the likelihood for this to be true?

Edit per comment: I have not considered $$0$$ as a perfect square.

Here are some examples of the early results:

$$5 = 1^2 + 1^2 + 3$$

$$7 = 2^2 + 1^2 + 2$$

$$9 = 1^2 + 1^2 + 7$$

$$11 = 2^2 + 2^2 + 3$$

$$13 = 2^2 + 2^2 + 5$$

$$15 = 2^2 + 2^2 + 7$$

$$17 = 1^2 + 3^2 + 7$$

$$19 = 2^2 + 2^2 + 11$$

$$21 = 2^2 + 2^2 + 13$$

$$23 = 3^2 + 3^2 + 5$$

$$29 = 3^2 + 3^2 + 11$$

$$31 = 5^2 + 2^2 + 2$$

$$33 = 3^2 + 1^2 + 23$$

$$35 = 3^2 + 3^2 + 17$$

$$37 = 3^2 + 3^2 + 19$$

$$39 = 5^2 + 1^2 + 13$$

$$41 = 1^2 + 3^2 + 31$$

$$43 = 4^2 + 2^2 + 23$$

$$45 = 6^2 + 2^2 + 5$$

$$47 = 6^2 + 2^2 + 7$$

$$49 = 1^2 + 5^2 + 23$$

$$51 = 6^2 + 2^2 + 11$$

$$53 = 6^2 + 2^2 + 13$$

$$55 = 3^2 + 3^2 + 37$$

,,,

• Probably not a question with an answer existing, we know the characterization of numbers which are the sum of two square, so, given your odd $n,$ we want a prime $p$ so that $n-p=m^2q$ where $q$ is square-free and has no prime factors $r\cong 3\pmod 4.$ But you’d need a lot more data than a hundred small examples to give an inkling that this might be true, Squares and primes are much more frequent with small examples. May 20, 2021 at 20:30
• @Thomas Andrews As a web developer, I know how to program in PhP, but i Just couldn't program to check it May 20, 2021 at 20:33
• If $0$ is not allowed, then add to my characterization $n-p=m^2q$ that you need either $m$ divisible by a prime $\equiv 1\pmod 4$ or $q\neq 1.$ May 20, 2021 at 20:35
• I.e. {2n+1} ⊆ {s + p : s ∈ A000415, p ∈ A000040} is the question. May 20, 2021 at 22:30
• Up to $10^5$, the only numbers that cannot be expressed in this fashion are: $1,2,3,6,14$. May 21, 2021 at 1:04

In 1923, Hardy and Littlewood [Some problems of “partitio numerorum”, III, Acta Math., 44 (1923), pp. 1-70] conjectured that all sufficiently large integers $$n$$ can be written in the form $$n=p+a^2+b^2$$ where $$p$$ is a prime, and $$a,b$$ are integers. In 1959–1960, Linnik [Hardy–Littlewood problem on the representation as the sum of a prime and two squares, Dokl. Akad. Nauk SSSR, 124 (1959), pp. 29-30 and An asymptotic formula in an additive problem of Hardy and Littlewood, Dokl. Akad. Nauk SSSR, 24 (1960), pp. 629-706] confirmed this conjecture.

See also Hooley, On the representation of a number as the sum of two squares and a prime.

• Just the link doesn’t work. Thanks. May 21, 2021 at 9:15
• I had a feeling it might not work, but I think if you paste the title of the paper into Google it ought to take you there. May 21, 2021 at 11:45

It would seem this is the case, at least from n=5 to $$n=10^7$$. I tested for each number using the following python code (you'll need to pip install sympy in order to run it, I used their prime functions because it's going to be faster than anything I could write)

**Note: I wasn't 100% sure how to account for the "I have not considered $$0$$ as a perfect square" rule, so I skipped the prime if n-prime was a perfect square. This only cut out $$38$$, as $$38$$ can only be represented as $$38 = 4^2 + 3^2 + 13$$, so just ignore this value. Otherwise, no other number seems to be caught in this.

import sympy

def prime_decomp(n):
decomp = []
for factor in sympy.primefactors(n):
c = 0
while n % factor == 0:
c += 1
n //= factor
decomp.append((factor, c))
return decomp

for n in range(5, 10 ** 7):
prime = 2
found = False
while prime < n:
if ((n-prime) ** 0.5 ).is_integer(): # Disable having 0 as a perfect square
prime = sympy.nextprime(prime)
continue
sots = True
for factor in prime_decomp(n-prime): # Check if n - prime can be made of 2 squares
# Sum of two squares theorem
if factor[0] % 4 == 3 and factor[1] % 2 == 1:
sots = False
break
if sots: # n - prime can be constructed with Sum Of Two Squares
found = True
break
prime = sympy.nextprime(prime)
if not(found):
print(n)


Edit:

Looking at this probabilistically, it seems highly unlikely that any large enough number couldn't be represented in this way, simply because there are just so many opportunities for the number to be represented, and quite often large numbers are hardly different at all to small ones in their prime factorization meaning they are no less likely to be a sum of two squares. This is all very vague, and there's no concrete maths behind my speculation, but I would say the likelihood of finding a number that can't be made from a prime and a sum of two squares would decrease with $$n$$