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

Version Path
trackler-2.2.1.180 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.179 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.178 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.177 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.176 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.175 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.174 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.173 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.172 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.171 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.170 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.169 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.167 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.166 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.165 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.164 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.163 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.162 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.161 tracks/fsharp/exercises/perfect-numbers/Example.fs
trackler-2.2.1.160 tracks/fsharp/exercises/perfect-numbers/Example.fs