Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Created November 21, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adilakhter/4125620 to your computer and use it in GitHub Desktop.
Save adilakhter/4125620 to your computer and use it in GitHub Desktop.
isprime
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