Write an integral binary quadratic form as
A positive definite form is a reduced positive definite binary quadratic form when
with on the boundary or . The class number of a negative discriminant is the number of proper equivalence classes of primitive positive definite integral forms of discriminant .
Every such class has a reduced representative. For a reduced form,
so
There are only finitely many possible integers and , and then
is determined. Hence . There is at least one class: the principal form is
and
Thus , in agreement with the enumeration of reduced binary quadratic forms.
Now let be prime. The two forms
are primitive, positive definite, reduced, and have discriminant . They are not properly equivalent: represents one, while the least positive value of is two. Therefore
Assume henceforth that , so these are the only two classes. If
for a prime , then is odd and
Moreover , so is a quadratic residue modulo . This proves the necessity.
Conversely, suppose and is a quadratic residue modulo . By quadratic reciprocity, these two conditions imply
Indeed, for both relevant signs are positive, while for the signs from and reciprocity with cancel. Choose an even integer such that
Then
is a primitive positive definite integral form of discriminant and represents . It belongs to one of the two classes .
The second form cannot represent such a prime. If
then is odd and, since ,
This contradicts . Hence lies in the principal class , and proper equivalence of binary quadratic forms preserves represented integers. Therefore
This is the prime representation when h of minus eight q equals two.