Skip to content

Instantly share code, notes, and snippets.

@kazua
Created November 13, 2012 16:31
Show Gist options
  • Save kazua/4066785 to your computer and use it in GitHub Desktop.
Save kazua/4066785 to your computer and use it in GitHub Desktop.
Project Euler Problem 20
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2020
//K.A
object problem20 {
def sum(acl : Int, xs : List[String]) : Int = xs match {
case Nil => acl
case y :: ys => sum(acl + y.toInt, ys)
}
def problem20(is : Int) : Int ={
sum(0,(BigInt(1) to is).reverse.product.toString.split("").filter(_ != "").toList)
}
def main(args : Array[String]) {
val ploblem20k = problem20 _
println(ploblem20k(100))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment