Created
March 19, 2012 20:45
-
-
Save dnene/2126982 to your computer and use it in GitHub Desktop.
Find prime numbers between 1 and 100
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
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