Skip to content

Instantly share code, notes, and snippets.

@sunphiz
Last active December 16, 2015 23:59
Show Gist options
  • Save sunphiz/5517809 to your computer and use it in GitHub Desktop.
Save sunphiz/5517809 to your computer and use it in GitHub Desktop.
package me.sunphiz
object p004 extends App {
def run: String = {
var maxPalin = -1
for (i <- 1000 to 100 by -1; j <- 1000 to 100 by -1) {
var prod = i * j
if (isPalindrome(prod.toString) && prod > maxPalin) maxPalin = prod
}
maxPalin.toString
}
def isPalindrome(s: String) =
s == s.reverse.toString;
println(run);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment