Skip to content

Instantly share code, notes, and snippets.

@rahatarmanahmed
Created December 12, 2013 00:11
Show Gist options
  • Save rahatarmanahmed/7921007 to your computer and use it in GitHub Desktop.
Save rahatarmanahmed/7921007 to your computer and use it in GitHub Desktop.
isPrime function in coffeescript
isPrime = (n) ->
return false if n isnt ~~n or n <= 1 or n % 2 is 0 and n isnt 2
return false for r in [3..Math.ceil(Math.sqrt(n))] by 2 when n % r is 0
return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment