Perfect Numbers tests does not finish in F#

I’m currently trying to submit my proposed solution to the Perfect Numbers exercise in F#.

Until now, I was not able to make the automated tests finish.

My code submission:

module PerfectNumbers

type Classification =
    | Perfect
    | Abundant
    | Deficient 

let rec getAliquotSum (number: int) (state: int) (out: int list): int =
    if (state = number) then out |> List.sum
        match (number % state) with
        | 0 -> getAliquotSum number (state + 1) (state::out)
        | _ -> getAliquotSum number (state + 1) out

let classify (number: int): Classification option =
    if (number < 1) then None
        let aliquotSum = getAliquotSum number 2 [1]

        if (aliquotSum = number) then Some Classification.Perfect
        elif (aliquotSum > number) then Some Classification.Abundant
        else Some Classification.Deficient

The automated tests error:


Your tests timed out. This might mean that there was an issue in our infrastructure, but more likely it suggests that your code is running slowly. Is there an infinite loop or something similar?

Please check your code, and if nothing seems to be wrong, try running the tests again.

I have tested the algorithm locally with different inputs and all of them worked fine.

// Perfect:
classify 6
classify 28
// Abundant:
classify 12
classify 24
// Deficient:
classify 8
classify 13
// Wrong input:
classify 0
classify -1

I have kind of a similar experience with my FSharp solutions. They pass locally, I submit them, they pass on the server, I finish the exercise and leave it for a few days. When I come back, the single submitted iteration sometimes appears with failed tests.

For example, right now I found failing test due to time out for my second iteration of the “Reverse string” exercise. The code under test is let reverse = Seq.rev >> Seq.toArray >> System.String which should only be able to time out if the test runner takes too long to get going.