Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def max_factor(num):
    """Find the maximum prime factor."""
    factor = 2
    while factor * factor <= num:
        while num % factor == 0:
            num /= factor
        if (num == 1):
            break
        factor += 1
    if (num > 1):
        return num
    return factor

print max_factor(8) #2
print max_factor(33) #11
print max_factor(38) #19
print max_factor(600851475143) #6857