Calculating the class number h(d) for binary quadratic forms of positive discriminant d

h(d) is listed for all discriminants d in the range m ≤ d ≤ n, where m < 106.
We locate all reduced irrationals of the form (b+√d)/(2|c|), where c is negative and 4c divides d-b2. We use the PQa continued fraction algorithm of Lagrange to break the set into disjoint cycles, retaining one number from each cycle. Each reduced number then gives rise to a reduced form (a,b,c) of discriminant d, where a=(b2-d)/(4c).
We are able to also determine if the Pell equation x2-dy2=-4 has a solution, by using the fact that the equation is soluble iff at least one of the above cycles is odd.

We write the output as h(d)- or h(d)+, according as the negative Pell equation is, or is not, soluble.

(See note and Henri Cohen p. 260, A course in computational number theory, First Edition.)

Also see tables generated via this page.

Enter m (1 ≤ m < 1010 ):
Enter n (1 ≤ m ≤ n < 1010 ):

All discriminants
fundamental discriminants
odd fundamental discriminants
even fundamental discriminants

Last modified 10 July 2014
Return to main page