quadratic_class_number.sage (425B)
1 # Determines the proportion of real quadratic fields with odd class number. 2 def f(B): 3 sqf = [ b for b in range(2,B) if b%4==1 and is_squarefree(b) ] 4 total_odd = 0 5 6 R.<x> = PolynomialRing(QQ) 7 for a in sqf: 8 if NumberField( x^2 - a, 'c' ).class_number() % 2 == 1: 9 total_odd += 1 10 11 print "=1 mod 4 squarefree integers up to", B, ": ", len(sqf) 12 print "With odd class number:", total_odd