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 | |
} |
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 p003 extends App { | |
def run(n: Long, p : Long = 2L): Long = { | |
var sp = smallestFactor(n, p) | |
if (sp < n) | |
run(n / sp, sp) | |
else | |
return n | |
} |