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
class Complex(real: Double, imaginary: Double) { | |
def re() = real | |
def im() = imaginary | |
override def toString() = | |
"" + re + (if (im < 0) "" else "+") + im + "i" | |
} |
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
import scala.math | |
object largestprime { | |
val initNumber:Long = 600851475143L //> initNumber : Long = 600851475143 | |
def IsPrimeNumber(p:Long):Boolean = { | |
if(p < 10){ p == 2 || p== 3 || p== 5 || p== 7} | |
else{ p % 2 != 0 && p % 3 != 0 && p % 5 != 0 && p % 7 != 0 } | |
} //> IsPrimeNumber: (p: Long)Boolean |