Skip to content

Instantly share code, notes, and snippets.

View Complex.scala
class Complex(real: Double, imaginary: Double) {
def re() = real
def im() = imaginary
override def toString() =
"" + re + (if (im < 0) "" else "+") + im + "i"
}
@davidgraca
davidgraca / euler3.scala
Created Feb 2, 2017
Euler problem no3 in Scala
View euler3.scala
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