# Write $n^2$ as $x^2+y^2+2\times4^z$ or $x^2+y^2+5\times 4^z$

In March 2018, I formulated the following somewhat curious question.

Question 1. Whether for any integer $$n>1$$ there is a nonnegative integer $$k$$ such that $$n^2-2\times 4^k$$ or $$n^2-5\times 4^k$$ is a sum of two squares?

See https://oeis.org/A300510 for the history of this question. In June 2019, via a computer G. Resta found that the question has a positive answer for all $$n=2,\ldots,6\times10^9$$.

In March 2018, I also formulated another similar question.

Question 2. Whether for any integer $$n>1$$ we can write $$n^2$$ as $$x^2+2y^2+2\times4^z$$ or $$x^2+2y^2+3\times4^z$$ with $$x,y,z$$ nonnegative integers?

My computation indicates that Question 2 has a positive answer for all $$n=2,\ldots,5\times10^7$$. See http://oeis.org/A301452.

Can one find a counterexample to Question 1 or Question 2?

• Question 1 was motivated by writing $n^2$ in a nontrivial way as a sum of four squares. – Zhi-Wei Sun Apr 8 at 12:04

Search $$n$$ for which no solutions.

Q1.1.

$$x^2+y^2=n^2-2\cdot4^z$$

2, 881, 1762, 3524, 7048, 10467, 14096, 15713, 17841, 18511, 20511, 20934, 23623, 28192, ...


gp-code:

nxyz()=
{
for(n=2, 10^5,
zm= 0;
while(2*4^zm<n^2, zm++); zm= zm-1;
t= 0;
for(z=1, zm,
T= thue('x^2+1, n^2-2*4^z);
if(#T, t= 1)
);
if(!t, print1(n", "))
)
};


Q1.2.

$$x^2+y^2=n^2-5\cdot4^z$$

2, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ...


gp-code:

  ...
while(5*4^zm<n^2, zm++); zm= zm-1;
...
T= thue('x^2+1, n^2-5*4^z);
...


Q2.1.

$$x^2+2y^2=n^2-2\cdot4^z$$

2, 881, 1762, 3524, 7048, 10467, 14096, 15713, 17841, 18511, 20511, 20934, 23623, 28192, 31147, ...


gp-code:

  ...
while(2*4^zm<n^2, zm++); zm= zm-1;
...
T= thue('x^2+2, n^2-2*4^z);
...


Q2.2.

$$x^2+2y^2=n^2-3\cdot4^z$$

2, 3, 5, 3215, 6430, 6917, 19187, 25717, 73413, ...


gp-code:

  ...
while(3*4^zm<n^2, zm++); zm= zm-1;
...
T= thue('x^2+2, n^2-3*4^z);
...

• Could you clarify what this code does? It seems like just a bunch of random numbers and I am havibg trouble parsing the code. – Wojowu Apr 9 at 8:32
• @Wojowu search $n$ for which no solutions – Dmitry Ezhov Apr 9 at 9:04
• So are these counterexamples to the original question? – Wojowu Apr 9 at 9:19
• @Wojowu yes, it is – Dmitry Ezhov Apr 9 at 9:24
• This is not an answer. You give no counterexample. Please note the word or in the two questions. – Zhi-Wei Sun Apr 9 at 9:32