Solution to Project Euler problem 4
package problem4
object problem4 {
def isPalindrome(x: String) : Boolean = {
var i = 0
var j = x.length() - 1
while(i <= j) {
if (x.charAt(i) != x.charAt(j))
return false
i += 1
j -= 1
}
return true
}
def main(args: Array[String]): Unit = {
var max = 0
for(i <- 100 to 1000) {
for(j <- 100 to 1000) {
var prod = i * j
var prodStr = prod.toString()
if (isPalindrome(prodStr)) {
max = Math.max(max, prod)
}
}
}
println(max)
}
}