Solve problem 110.

This commit is contained in:
2024-03-31 12:50:44 -04:00
parent dd89390a04
commit 303eae42c9
2 changed files with 83 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
from fractions import Fraction
from lib_misc import proper_divisors
from math import ceil
def get_distinct_solutions(n):
@@ -16,11 +18,16 @@ def get_distinct_solutions(n):
return n_distinct
def get_distinct_solutions2(n):
ds = proper_divisors(n * n)
return ceil((len(ds) + 1) / 2)
def euler_108():
d_max, n_prev = 0, 0
# I arrived at the starting values empirically by observing the deltas.
for n in range(1260, 1000000, 420):
d = get_distinct_solutions(n)
d = get_distinct_solutions2(n)
if d > d_max:
# print("n={} d={} delta={}".format(n, d, n - n_prev))
n_prev = n