Created
June 5, 2012 14:05
-
-
Save dungpa/2875216 to your computer and use it in GitHub Desktop.
A sequence of prime under n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec primesUnder = function | |
| n when n<=2 -> [||] | |
| 3 -> [|2|] | |
| n -> let ns = n |> float |> sqrt |> ceil |> int | |
let smallers = primesUnder ns | |
Array.append smallers (filterRange (indivisible smallers) (ns, n-1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment