Ask Your Question

Revision history [back]

Line 5: Integer(n)/Integer(n) should probably have Integer(m) in the denominator.

Line 5: replace & with in ZZ and. Actually, Integer(n)/1 will always be in ZZ. Maybe you should just have if Integer(n)/Integer(m) in ZZ: or if Integer(m).divides(n): but I'm not quite sure what you're looking for.

Last line: replace prime_divisor_list with prime_list.

Last line: should be indented four spaces.

So:

def com_primes(k):
    prime_list = []
    for n in range(1,k+1):
        for m in range(1,n+1):
            if Integer(m).divides(n):
                if is_prime(m):
                    prime_list.append((n,m))
    return point(prime_list)