Scala: Project Euler: Problem 6
November 25th, 2009
Problem:
What is the difference between the sum of the squares and the square of the sums?
object Problem6 {
def main(args: Array[String]) :Unit = {
println(solve(100))
}
def solve(number:Int) : Int = {
var sum = 0
for {
i <- 1.to(number-1)
j <- (i+1).to(number)
} sum += 2 * i * j
return sum
}
}