Created
November 13, 2012 16:31
-
-
Save kazua/4066785 to your computer and use it in GitHub Desktop.
Project Euler Problem 20
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
//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