// Primes in F# // This code is placed into the public domain. #light let divisible_by n = List.filter (fun m -> m % n <> 0) let sieve max = let rec sieve_aux = function | [] -> [] | x :: xs as l -> if x * x > max then l else x :: sieve_aux (divisible_by x xs) sieve_aux [2 .. max]