Representation of Positive Integers by Binary Quadratic Forms This is a follow up to a question from yesterday regarding the representation of integers by binary quadratic forms with integer coefficients.  OEIS A031363 lists the positive integers of the form $x^2+xy-y^2$ which turn out to be the same as those of the form $5x^2-y^2.$   Yesterday's question was how to show the two sets are the same, but I notice that on the OEIS page, it says, under "Formula:

Consists exactly of numbers in which primes == 2 or 3 mod 5 occur with even exponents.  

I've been wondering what it takes to prove this, in particular whether it can be shown by elementary methods, since I know no algebraic number theory at all.    
I think it's likely to be much easier to prove that numbers not of this form can't be represented than to prove the converse, so I'm starting with that.
For $p=2$ it says, no $n \equiv 2 \pmod 4$ can be so represented, and it's trivial to check that $5x^2-y^2$ cannot be of this form, since the only squares $\pmod 4$ are $0 \text{ and }1.$
For a general attack, I'm thinking about trying to show that $n$ is representable if and only if each of its prime factors is representable.  If true, this would reduce the problem to representability of primes. I have some confidence in the "if" part (at least I know that the sum of two squares times the sum of two squares is again the sum of two squares) but I have no feeling for the "only if" part at all.  Since $k^2n$ is representable if and only if $n$ is representable (from the form $5x^2-y^2),$ and $1$ is we don't need to consider powers.  
This isn't something I need for school or work. I'm retired and sometimes do math for recreation; I want to know if this is a suitable problem for me to work on, that is, one that offers a reasonable chance of success, or at least progress.  I'm not asking for a proof; I just want to have some idea of the level of difficulty of the problem.             
 A: Gauss's theory of quadratic forms can answer all these questions. The form 
$$x^2+xy+y^2$$ is easy though, it has discriminant $D=5$. All forms of discriminat $5$ are equivalent, (via linear transform with discriminant $1$).
The condition for a prime $n$ to be represented by a form of discriminant $5$ is that $$x^2\equiv 5 \pmod {4n}$$
 be solvable, in other words that all primes $p$ dividing $n$, we have 
$$\left(\frac{5}{p}\right)=+1$$
And by quadratic reciprocity, 
$$\left(\frac{5}{p}\right)=\left(\frac{p}{5}\right)$$ so we must have that 
$$p\equiv 1,4 \pmod{5}$$
This gives the numbers represented (primitively, that is rel prime $x,y$) by some form of discriminant $5$, but they are all equivalent so for the first form. Of course you can always multiply by a square. 
The second form has discriminant $D=20$, in this case there are two non equivalent forms, 
$$2x^2+2xy-2y^2$$  and 
$$x^2+4xy-y^2\sim 5x^2-y^2$$ now the first form is just twice the first form and the coefficients are not rel. prime, so we can discount it. Here the condition to be represented, by the second form will be 
$$x^2\equiv 20 \pmod {4n}$$
And since $4$ is a perfect square this is equivalent to 
$$x^2\equiv 5 \pmod {n}$$ and so we get exactly the same answer as the first case, which is what we expected to see.
A: Suppose $(5|p) = 1$ for prime $p > 10.$ We can solve
$$ t^2 \equiv 5 \pmod p.  $$ If necessary by switching to $p-t,$ we can arranged that $t$ is odd, in which case we have actually solved
$$ t^2 \equiv 5 \pmod {4p}, $$ or
$$ t^2 = 5 + 4 p w,  $$
$$  t^2 - 4 p w = 5.  $$
That means that $$  \langle p,t,w \rangle $$
are the ordered coefficients of a binary quadratic form of discriminant $5.$ By inequaities, we know that this form is $SL_2 \mathbb Z$ equivalent to $ \langle 1,1,-1 \rangle.$ That means there is an integer matrix with determinant $1$ such that
$$
\left(
\begin{array}{rr}
a & c \\
b & d
\end{array}
\right)
\left(
\begin{array}{rr}
2p & t \\
t & 2w
\end{array}
\right)
\left(
\begin{array}{rr}
a & b \\
c & d
\end{array}
\right) =
\left(
\begin{array}{rr}
2 & 1 \\
1 & -2
\end{array}
\right)
$$
This also means, with all integers,
$$
\left(
\begin{array}{rr}
d & -c \\
-b & a
\end{array}
\right)
\left(
\begin{array}{rr}
2 & 1 \\
1 & -2
\end{array}
\right)
\left(
\begin{array}{rr}
d & -b \\
-c & a
\end{array}
\right) =
\left(
\begin{array}{rr}
2p & t \\
t & 2w
\end{array}
\right)
$$
meaning
$$  d^2 + d (-c) - c^2 = p   $$  
Here is an example with $p = 241,$ where $103^2 \equiv 5 \pmod {241}$
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefCycle  241  103 11

  0  form            241         103          11  delta      4
  1  form             11         -15           5  delta     -2
  2  form              5          -5           1  delta     -2
  3  form              1           1          -1


           2          -3
          -9          14

To Return  
          14           3
           9           2

0  form   1 1 -1   delta  -1     ambiguous  
1  form   -1 1 1   delta  1     ambiguous            -1 composed with form zero  
2  form   1 1 -1


  form   1 x^2  + 1 x y  -1 y^2 

minimum was   1rep   x = 1   y = 0 disc 5 dSqrt 2  M_Ratio  4
Automorph, written on right of Gram matrix:  
-1  -1
-1  -2
=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ 

The matrix called "To Return" tells us that
$$ 14^2 + 14 \cdot 9 - 9^2 = 196 + 126 - 81 = 241 $$
