Last active
August 29, 2015 14:09
-
-
Save ecounysis/78ad1f7adb5f6d863e93 to your computer and use it in GitHub Desktop.
primes
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 divisors x = | |
List.init (int (Math.Sqrt(float x))) (fun x -> x + 1) | |
|> List.filter (fun y -> x % y = 0) | |
|> List.map (fun y -> [y ; x / y]) | |
|> List.reduce (fun x y -> x @ y) | |
|> List.sort | |
let isPrime x = | |
List.length (divisors x) = 2 | |
let primesBetween x y = | |
seq { for num in x..y do | |
if (isPrime num) | |
then yield num } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment