Skip to content

Instantly share code, notes, and snippets.

@rodrigovidal
Created October 19, 2011 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigovidal/1297382 to your computer and use it in GitHub Desktop.
Save rodrigovidal/1297382 to your computer and use it in GitHub Desktop.
Crivo de Eratostenes ainda lento...
open System
open System.Collections.Generic
let sieve n =
seq {
let hash = new HashSet<int64>()
yield 2L
for k in 3L..2L..System.Int64.MaxValue do
if not (hash.Contains k) then
yield k
for j in k..k..n do
hash.Add(j) |> ignore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment