18 lines
604 B
FSharp
18 lines
604 B
FSharp
module _12
|
|
open System
|
|
|
|
let fiveDivisorTriangle =
|
|
let root (n : int) = int( Math.Sqrt(float(n)) )
|
|
// observation: if number has a factor < sqrt(num), then it has a corresponding
|
|
// factor > sqrt(num)
|
|
let factorCount x = Seq.sum (seq { for i = 1 to root x do if x % i = 0 then yield 2 })
|
|
|
|
let result =
|
|
(1, 0) |> Seq.unfold (fun (num,acc) ->
|
|
Some(num + acc, (num + 1, num + acc)))
|
|
|> Seq.filter (fun x ->
|
|
let factCount = factorCount x
|
|
factCount >= 500 )
|
|
|> Seq.head
|
|
result
|