Sha256: 8b9d136552998bda8017d7ae6a3db63f169a55f7f39fbae06671f87ffa186c45
Contents?: true
Size: 403 Bytes
Versions: 131
Compression:
Stored size: 403 Bytes
Contents
module PerfectNumbers type Classification = Perfect | Abundant | Deficient let sumOfFactors n = [for x in 1..n / 2 do if n % x = 0 then yield x] |> List.sum let classify n : Classification option = match n with | x when x <= 0 -> None | _ -> match sumOfFactors n with | x when x = n -> Some Perfect | x when x < n -> Some Deficient | _ -> Some Abundant
Version data entries
131 entries across 131 versions & 1 rubygems