(* primes2.ml Prime number generator, take 2 Tyler Eaves *) exception Not_prime;; exception Its_Prime;; let rec isprime n primes = ( try List.iter (fun x -> if n mod x = 0 then raise Not_prime else if sqrt (float_of_int n) < (float_of_int x) then raise Its_Prime else ()) primes; Printf.printf "%d is PRIME!\n" n; isprime (n+2) (List.concat [primes; [n]]) with Not_prime -> isprime (n+2) primes | Its_Prime -> (Printf.printf "%d is PRIME!\n" n; isprime (n+2) (List.concat [primes; [n]])) );; isprime 3 [2];;