28 lines
687 B
FSharp
28 lines
687 B
FSharp
module _23
|
|
|
|
let abundantUpperLimit = 28123
|
|
|
|
let abundantNumbers =
|
|
let dSums =
|
|
common.divisors abundantUpperLimit
|
|
|> Array.mapi (fun i divisors -> (i, List.fold (+) 0 divisors))
|
|
dSums |> Array.choose ( fun (i, dSum) ->
|
|
match dSum with
|
|
| abundant when dSum > i -> Some(i)
|
|
| _ -> None
|
|
)
|
|
|
|
let sumNotAbundant =
|
|
let a = abundantNumbers
|
|
// add all abubundant numbers together
|
|
|
|
let sums = common.crossMap (+) a a |> Seq.distinct |> Seq.toArray
|
|
|
|
let sna =
|
|
sums
|
|
|> Set.ofSeq
|
|
|> (-) (Set.ofList [1..abundantUpperLimit])
|
|
|> Set.toSeq
|
|
//|> Array.rev
|
|
|
|
sna |> Seq.fold (+) 0 |