open System.Collections.Generic // open System.Diagnostics let sieveOfEratosthenes n = let isPrime = Array.create n true let primes = new List() Array.set isPrime 0 false Array.set isPrime 1 false for i = 2 to n - 1 do if isPrime.[i] then primes.Add(i) for j in 2 * i .. i .. n - 1 do Array.set isPrime j false primes let () = let n = 5000000 // let stopwatch = Stopwatch.StartNew() let primes = sieveOfEratosthenes n // stopwatch.Stop() // printfn "%.3f ms" stopwatch.Elapsed.TotalMilliseconds printfn "%d" 0