aboutsummaryrefslogtreecommitdiff
path: root/misc_code/ugly_computations/quadratic_class_number.sage
blob: a26dc500fde8a7e3f7adb9b689b85420922fe243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# Determines the proportion of real quadratic fields with odd class number.
def f(B):
    sqf = [ b for b in range(2,B) if b%4==1 and is_squarefree(b) ]
    total_odd = 0

    R.<x> = PolynomialRing(QQ)
    for a in sqf:
        if NumberField( x^2 - a, 'c' ).class_number() % 2 == 1:
            total_odd += 1

    print "=1 mod 4 squarefree integers up to", B, ": ", len(sqf)
    print "With odd class number:", total_odd

Generated with cgit - Back to sebastiano.tronto.net