Finding the class number h(d) of binary quadratic forms of negative discriminant d

Here d ≡ 0 (mod 4) or 1 (mod 4).
If flag value 1 is entered below, we print only the primitive forms.
If flag value 0 is entered, we print primitive and imprimitive forms.
h(d) is returned in each case.
H. Davenport's Higher Arithmetic has a table of forms, which lists the imprimitive ones with an asterisk.
If d is the discriminant of an imaginary quadratic field K, then the primitive forms class-number h(d) is also the class number of K.

(See Henri Cohen's Algorithm 5.3.5, p. 228, A course in computational number theory, First Edition.)

Enter d (d < 0 and d ≡ 0 or 1 (mod 4), |d| < 106 ):
Enter flag (0 or 1):

Last modified 12th May 2003
Return to main page