Add more solutions

This commit is contained in:
Kevin Keogh
2019-02-03 14:21:43 -05:00
parent 4ef32a7e04
commit fbebd6c05f
7 changed files with 147 additions and 0 deletions

20
problem-69.py Normal file
View 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)