以下の内容はhttps://inamori.hateblo.jp/entry/20110705/p1より取得しました。


ScalaでProject Euler(37)

Problem 20

これもProblem 16と同じです。

def mul(a :List[Int], m :Int, c :Int = 0) :List[Int] = a match {
    case Nil if c == 0 => Nil
    case Nil => (c % 10) :: mul(Nil, m, c / 10)
    case head :: tail => {
        val r = head * m + c
        r % 10 :: mul(tail, m, r / 10)
    }
}

val N = 100
val a = (1 to N).foldLeft(List(1))((x, y) => mul(x, y, 0))
println (a.sum)



以上の内容はhttps://inamori.hateblo.jp/entry/20110705/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14