Solve problem 110.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user