Created
November 21, 2012 15:56
-
-
Save adilakhter/4125620 to your computer and use it in GitHub Desktop.
isprime
This file contains 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 isprime n = | |
let rec isprimeAux i n = | |
i > n/2 || (n%i <> 0 && (isprimeAux (i+1) n)) | |
isprimeAux 2 n | |
//> output: | |
// | |
//val isprime : int -> bool | |
// | |
//> isprime 10;; | |
//val it : bool = false | |
//> isprime 11;; | |
//val it : bool = true | |
//> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment