Is there any variation known to the sum of two squares theorem? Originally posed by Fermat and subsequently generalized as sum of two squares theorem, we can see the following statement.
An integer greater than one can be written as a sum of two squares if and only if its prime decomposition contains no factor $p^k$, where prime $p\equiv 3 \pmod {4}$ and $k$ is odd.
My question is simple.
Is there any variation known to this theorem?
Such as, when we refer the theorem above as $1 \pmod {4}$ version, I would like to know whether there are any $1 \pmod {6}$ version, $1 \pmod {8}$ version, $1 \pmod {12}$ version...and so on.
The Diophantine equation won't have to be necessarily similar with the two square version.
Such as, someone might find some property of prime decomposition regarding some modular restriction with a Diophantine equation higher that the degree 2.
I've tried to make the question simple, but I'm not sure whether they could have been conveyed to the readers. If the points were not clear, please let me clarify them with further comments. Thanks.
Edit: My question was posed to ask for some variation in regard of modular restriction of prime decomposition. For example let's think about some formula A which is a Diophantine polynomial.
$$ A = n $$
when $A = a^2 + b^2$, it is sum of two squares theorem, which I refer as $1 \pmod {4}$ version. My main question is, whether there is any $A$ that makes $n$ on the right hand side being factorized only with $1 \pmod {6}$ numbers, or $1 \pmod {8}$ numbers, or $1 \pmod {12}$ numbers. If there is any, we may refer them as $1 \pmod {6}$ version, $1 \pmod {8}$ version, $1 \pmod {12}$ version. I see that already some of users are sharing their examples which I appreciate.
Thank you for your interests on my question.
 A: Is there any variation known to this theorem?
This is a very broad question, but yes, there are many.
For example Legendre's three square theorem and Jacobi's four square theorem.
Furthermore, the sum of two cubes, three cubes, e.g.,
$x^3+y^3+z^3=n$
which became famous lately for $n=42$.
Staying closer to the the square theorem, one can also look at
$$
ax^2+by^2=n
$$
and representations of integers by quadratic forms.
For example see
Representation of Positive Integers by Binary Quadratic Forms
A: The sum of two squares theorem can be proved by working in $\Bbb Z[i]$.
By working in $\Bbb Z[\zeta_3]$ instead, where $\zeta_3$ is a third root of unity, one may prove that an integer greater than one can be written in the form $a^2+3b^2$ (or equivalently, in the form $a^2+ab+b^2$, see the comments) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 2 \pmod{3}$.
There is a similar statement for every quadratic number field with class number one. This may be proved by using unique factorization in the ring of integers, quadratic reciprocity and the characterization of splitting of primes in quadratic extensions in terms of Legendre symbols.
Here are some more examples:
By working in $\Bbb Z[\sqrt{2}]$, one gets that an integer greater than one can be written in the form $a^2-2b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 3,5 \pmod{8}$.
By working in $\Bbb Z[\sqrt{-2}]$, one gets that an integer greater than one can be written in the form $a^2+2b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 5,7 \pmod{8}$.
By working in $\Bbb Z[\frac{1+\sqrt{-19}}{2}]$, one gets that an integer greater than one can be expressed as $a^2+ab+5b^2$ if and only if its prime decomposition contains no factor of the form $p^k$, where $k$ is odd and $p=2$ or $p\equiv 3,4,8,10,12,13,14,15,18$. Note that the quadratic form here is non-diagonal, because the ring of integers of $\Bbb Q(\sqrt{-19})$ is not $\Bbb Z[\sqrt{-19}]$.
There's another phenomenon that these examples so far haven't covered. If the number field is real quadratic and there is no unit with norm $-1$ in $\mathcal O_K$, then we need to introduce a $\pm$ in the quadratic form to get a correct statement.
For example, in $\Bbb Z[\sqrt{7}]$ one has the fundamental unit $3\sqrt{7}-8$ with norm $1$, and so one gets that  that an integer greater than one can be written in the form $\pm(a^2-7b^2)$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 5,11,13,15,17,23 \pmod{28}$.
It is conjectured that there infinitely many real quadratic number fields of class number $1$, so if that conjecture holds, we get infinitely many such theorems. (LMFDB lists 177168 examples)
Here's the general theorem that may be specialized using some Legendre symbol computations (i.e. qudratic reciprocity) to give congruence conditions:
Theorem Let $K=\Bbb Q(\sqrt{D})$ be a quadratic number field with $D$ square-free and suppose that the ring of integers $\mathcal O_K$ has class number $1$. We have six cases:

*

*$D<0$ and $D \not\equiv 1 \pmod 4$

*$D<0$ and $D\equiv 1 \pmod 8$

*$D<0$ and $D\equiv 5 \pmod 8$

*$D>0$ and $D \not\equiv 1 \pmod 4$

*$D>0$ and $D \equiv 1 \pmod 8$

*$D>0$ and $D \equiv 5 \pmod 8$
For the cases 4-6, we have two subcases each:
a) the fundamental unit of $\mathcal O_K$ has norm $-1$
b) the fundamental unit of $\mathcal O_K$ has norm $1$
We then have the following properties:

*

*An integer greater than one can be written in the form $a^2-Db^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$

*An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $p=2$ or $\left(\frac{D}{p}\right)=-1$

*An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$

*An integer greater than one can be written in the form $a^2-Db^2$ (in subcase a) or in the form $\pm(a^2-Db^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$

*An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ (in subcase a) or in the form $\pm(a^2+ab+\frac{1-D}{4}b^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $p=2$ or $\left(\frac{D}{p}\right)=-1$

*An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ (in subcase a) or in the form $\pm(a^2+ab+\frac{1-D}{4}b^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$
