# Revision history [back]

The method class_number gives you the answer, there is no need for further methods

sage: QuadraticField(2).class_number()
1
2


For a number field, the fractional ideals form a group under multiplication. The class number is the number of elements in the quotient of this ring by the principal ideals. Hence, the class number is 1 if and only if the number field is a PID.

sage: QuadraticField(2).class_number()