In the following equation $x$, $y$, and $n$ are positive integers.
$$\frac 1 x + \frac 1 y = \frac 1 n$$It can be verified that when $n = 1260$ there are $113$ distinct solutions and this is the least value of $n$ for which the total number of distinct solutions exceeds one hundred.
What is the least value of $n$ for which the number of distinct solutions exceeds four million?
NOTE: This problem is a much more difficult version of problem 108 and as it is well beyond the limitations of a brute force approach it requires a clever implementation.
In [7]:
open Euler
let p110() =
let n = 1260
let k = 12 // started at 15 and went down until answer repeated
let step = Math.Primes |> Seq.take k |> Seq.fold ( * ) 1L
let solutions (n:int64) = (Math.DivisorSigma(2, n) + 1) / 2
let rec answer guess =
if solutions guess < 4000000 then
answer (guess + step)
else guess
answer step
Euler.Timer(p110)
Out[7]:
In [ ]: