21 lines
439 B
Python
21 lines
439 B
Python
|
|
from math import gcd
|
|
|
|
MAX_NUM = 1000000
|
|
|
|
def is_coprime(a, b):
|
|
return gcd(a, b) == 1
|
|
|
|
|
|
if __name__ == '__main__':
|
|
greatest_ratio = (0, 0)
|
|
for n in range(2, MAX_NUM+1):
|
|
if n % 10000 == 0:
|
|
print(n)
|
|
relative_primes = len([x for x in range(2, n) if is_coprime(x, n)]) + 1
|
|
if n/relative_primes > greatest_ratio[1]:
|
|
greatest_ratio = (n, n/relative_primes)
|
|
print(greatest_ratio)
|
|
|
|
|