after looking at the pseudocode for the Sieve of Eratosthenes on wikipedia I tried implementing a similar version using F#. The code runs just fine, that is, it returns all prime numbers up until a given number. But I was wondering if the implementation could be improved. See below for the code:
let rec sieve xs count maxNumb = match count = maxNumb with | true -> xs | false when (Array.contains count xs) -> xs |> Array.filter (fun ys -> ys % count <> 0. || ys = count) |> fun filteredArr -> sieve filteredArr (count + 1.) maxNumb | false -> sieve xs (count + 1.) maxNumb let findPrimes maxNumb = sieve [|2. .. maxNumb|] 2. maxNumb findPrimes 30. [|2.0; 3.0; 5.0; 7.0; 11.0; 13.0; 17.0; 19.0; 23.0; 29.0|] Thank you in advance for any comments or remarks :)