Skip to content

Instantly share code, notes, and snippets.

View davidgraca's full-sized avatar

David Graça davidgraca

View GitHub Profile
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 February 2, 2017 16:48
Euler problem no3 in 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