Skip to content

Instantly share code, notes, and snippets.

@dnene
Created March 19, 2012 20:45
Show Gist options
  • Save dnene/2126982 to your computer and use it in GitHub Desktop.
Save dnene/2126982 to your computer and use it in GitHub Desktop.
Find prime numbers between 1 and 100
package misc
import scala.math
object Prime {
def prime(num: Int) =
num > 1 &&
(2 to (math.sqrt(num) toInt)).forall ( num % _ != 0)
def main(args: Array[String]): Unit = {
1 to 100 filter prime foreach println
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment