SHARE
TWEET

Untitled

a guest Mar 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. object Test {
  2.   def main(args: Array[String]): Unit = {
  3.     var args=Array("14", "0", "2", "4", "8")
  4.     println(args.toList)
  5.     val zzz = new PrimeNumber(args(0).toInt)
  6.     var xxx=zzz.calculatePrimeNumbers().toList
  7.     println(xxx)
  8.   }
  9.  
  10.   def number(M:Int): Unit = {
  11.  
  12.   }
  13. }
  14.  
  15. class PrimeNumber(val N:Int) extends AnyVal {
  16.   def calculatePrimeNumbers() = {
  17.     val isPrime = collection.mutable.BitSet(2 to N: _*) -- (4 to N by 2)
  18.     for (p <- 2 +: (3 to Math.sqrt(N).toInt by 2) if isPrime(p)) {
  19.       isPrime --= p*p to N by p
  20.     }
  21.     isPrime.toImmutable
  22.   }
  23. }
  24.  
  25.  
  26. co wcyhodzi:
  27.  
  28. List(14, 0, 2, 4, 8)
  29. List(2, 3, 5, 7, 11, 13)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top