TITLE: Can the integers $n$ expressible as $2a^2-3b^2$ be classified?
QUESTION [6 upvotes]: Let $S$ be the set of integers $n$ that are expressible with $$n=2a^2-3b^2$$ with integers $a,b$

Can $S$ be classified by an iff-condition that allows to decide whether $n\in S$ , when the factorization of $n$ is known ?

I found out several partial results, but I could not find a final structure.
What I found out :

The residues $1$ and $3$ modulo $8$ are impossible as well as the residue $1$ modulo $3$
A prime $p\ge 5$ can only be in $S$, when $p\equiv 5\mod 24$ or $p\equiv 23\mod 24$
$n\in S$ if and only if the pell-like equation $$c^2-6b^2=2n$$ has an integer solution
A non-zero perfect square (including $1$) cannot be in $S$

Looking at the impossible residues modulo $2^k$, it seems that for $k\ge 3$ there are $2^{k-1}-2$ impossible residues, so with every additional factor $2$, $2$ new impossible residues occur. Is this true, and if, why ? Also, the residue $3^k$ modulo $3^{k+1}$ seems to be impossible. Again, is this true, and if , why ?

REPLY [4 votes]: Yes, they can be classified. 
It is an even/odd thing. Names are due to Irving Kaplansky, used between us and never put in writing. This was about 1994. 
A number is represented primitively if all prime factors are among $2,3$ and $1,5,19,23 \pmod{24}$ AND the sum of exponents of the medium primes  IS ODD.
The "good" primes are $3$ and all primes $1,19 \pmod{24}$
The "bad" primes are   all  $7, 11, 13, 17  \pmod{24}.$
A number cannot be represented at all unless the exponent of each bad prime is even. To get a primitive representation no bad primes can be factors at all.
The "medium" primes are $2$ and all primes $5,23 \pmod{24}$ as you noted. Let us also take $-1$ as a " medium prime."
The names are due to Irving Kaplansky, this is how he told me in cases of exactly two genera of binary quadratic forms, one class per genus.
jagy@phobeusjunior:~$ ./Conway_Positive_Primitive   2 0 -3  350
           2           0          -3   original form 

           2           4          -1   Lagrange-Gauss reduced 
Primitively represented positive integers up to  350

           2 = 2
           5 = 5
           6 = 2 * 3
          15 = 3 * 5
          23 = 23
          29 = 29
          38 = 2 * 19
          47 = 47
          50 = 2 * 5^2
          53 = 53
          69 = 3 * 23
          71 = 71
          86 = 2 * 43
          87 = 3 * 29
          95 = 5 * 19
         101 = 101
         114 = 2 * 3 * 19
         125 = 5^3
         134 = 2 * 67
         141 = 3 * 47
         146 = 2 * 73
         149 = 149
         150 = 2 * 3 * 5^2
         159 = 3 * 53
         167 = 167
         173 = 173
         191 = 191
         194 = 2 * 97
         197 = 197
         213 = 3 * 71
         215 = 5 * 43
         230 = 2 * 5 * 23
         239 = 239
         258 = 2 * 3 * 43
         263 = 263
         269 = 269
         278 = 2 * 139
         285 = 3 * 5 * 19
         290 = 2 * 5 * 29
         293 = 293
         303 = 3 * 101
         311 = 311
         317 = 317
         326 = 2 * 163
         335 = 5 * 67


 Primitively represented positive integers up to  350

           2           0          -3   original form