Skip to content

Instantly share code, notes, and snippets.

@kozake
Last active December 10, 2015 02:29
Show Gist options
  • Save kozake/4368214 to your computer and use it in GitHub Desktop.
Save kozake/4368214 to your computer and use it in GitHub Desktop.
Project Euler Problem 9
/**
* Project Euler Problem 9
*/
object P9 {
def isPythagorasNumber(a:Int, b:Int, c:Int):Boolean = a < b && b < c && BigInt(a).pow(2) + BigInt(b).pow(2) == BigInt(c).pow(2)
def answer = {
val list = for (i <- 1 to 333; j <- (i + 1) to 500; k <- (j + 1) to 1000; if((i + j + k) == 1000 && isPythagorasNumber(i, j, k))) yield (i, j, k)
val ans = list(0)
ans._1 * ans._2 * ans._3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment