aboutsummaryrefslogtreecommitdiff
path: root/misc_code/ugly_computations/GL2_ZN.py
blob: c7067032ca91eb0b0ac17d79a705e7127820f149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Prints a list of matrices, the elements of GL_2(Z/nZ)

def gcd( m, n ):
    if n == 0:
        return m
    return gcd( n, m%n )

def print_mat( a, b, c, d ):
    print ""
    print "|", a, " ", b, "|"
    print "|", c, " ", d, "|"

n = input("Choose n: ")

count = 0
for a in range(n):
    for b in range(n):
        for c in range(n):
            for d in range(n):
                if gcd( n, abs(a*d-b*c)) == 1:
                    print_mat(a,b,c,d)
                    count += 1

print "Found", count, "elements"

Generated with cgit - Back to sebastiano.tronto.net