Sha256: b399b9d5c08b6efb06c898b74ee5caead113f10b1340c632a270333669804127
Contents?: true
Size: 551 Bytes
Versions: 131
Compression:
Stored size: 551 Bytes
Contents
module NthPrime open System let isPrime (n: int) = let r = Math.Floor(Math.Sqrt(n |> double)) |> int r < 5 || Seq.init (r - 4) id |> Seq.forall (fun x -> n % (5 + x) <> 0) let rec possiblePrimes n = seq { yield n - 1 yield n + 1 yield! possiblePrimes (n + 6) } let primes = seq { yield 2 yield 3 yield! Seq.filter isPrime (possiblePrimes 6) } let prime nth : int option = match nth with | n when n < 1 -> None | _ -> Some (Seq.item (nth - 1) primes)
Version data entries
131 entries across 131 versions & 1 rubygems