Solved 72 in Python.
This commit is contained in:
@@ -29,6 +29,22 @@ def euler_071():
|
||||
return n_min
|
||||
|
||||
|
||||
def euler_071_farey():
|
||||
"""
|
||||
https://www.cut-the-knot.org/blue/Farey.shtml
|
||||
n_min must be located between 2/5 and 3/7 for F_7
|
||||
To calculate F_d where d <= 10**6 we continously calculate the
|
||||
median between 3/7 and the new fraction.
|
||||
"""
|
||||
n, d = (3, 7)
|
||||
n_D, d_D = (2, 5)
|
||||
while d_D + d <= 10**6:
|
||||
n_D = n_D + n
|
||||
d_D = d_D + d
|
||||
return n_D
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(euler_071_farey())
|
||||
print("e071.py: " + str(euler_071()))
|
||||
assert(euler_071() == 428570)
|
||||
|
||||
Reference in New Issue
Block a user