Skip to content

Instantly share code, notes, and snippets.

@kazua
Created January 21, 2013 13:13
Show Gist options
  • Save kazua/4585930 to your computer and use it in GitHub Desktop.
Save kazua/4585930 to your computer and use it in GitHub Desktop.
Project Euler Problem 55
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2055
//K.A
object problem55 {
def bolLychrel(nm : BigInt, acl : Int) : Boolean = nm match {
case a if (a + BigInt(a.toString.reverse)).toString == (a + BigInt(a.toString.reverse)).toString.reverse => false
case a => if (acl < 50) bolLychrel(a + BigInt(a.toString.reverse), acl + 1) else true
}
def problem55 = (1 until 10000).map(i => bolLychrel(i, 0)).filter(_ == true).size
def main(args : Array[String]) {
println(problem55)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment