Last active
December 16, 2015 23:59
-
-
Save sunphiz/5517809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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