Add more solutions
This commit is contained in:
20
problem-69.py
Normal file
20
problem-69.py
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user