Skip to content

Instantly share code, notes, and snippets.

@stingh711
Created August 22, 2012 05:51
Show Gist options
  • Select an option

  • Save stingh711/3422677 to your computer and use it in GitHub Desktop.

Select an option

Save stingh711/3422677 to your computer and use it in GitHub Desktop.
Project euler problem 4 solution
object Issue4 {
val MIN = 100
val MAX = 999
def isPalindromic(n: Int) = {
val s = n.toString
s == s.reverse
}
def maxPalindromic() = {
val palindromics = for (i:Int <- MAX.to(MIN, -1); j:Int <- MAX.to(MIN, -1); n = i * j; if (isPalindromic(n)))
yield n
palindromics.max
}
def main(args: Array[String]) {
assert(906609 == maxPalindromic())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment