Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** simple scala function to test is a number is a prime number **/
- def isPrime(p: Int): Boolean = {
- val p1=math.abs(p)
- if (p1 <= 3) return true
- var t: Int = math.sqrt(p1).asInstanceOf[Int]
- for ( i <- 2 to t if p1 % i == 0) return false
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement