これも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)