ONLY DO WHAT ONLY YOU CAN DO

こけたら立ちなはれ 立ったら歩きなはれ

Scala で Project Euler Problem 20

scala> List.range(1, 100).product
res0: Int = 0
scala> List.range(BigInt(1), BigInt(100)).product
<console>:6: error: type mismatch;
 found   : scala.math.BigInt
 required: Int
       List.range(BigInt(1), BigInt(100)).product
                        ^
scala> List.range(BigInt(1), BigInt(100)).reduceLeft(_*_)
<console>:6: error: type mismatch;
 found   : scala.math.BigInt
 required: Int
       List.range(BigInt(1), BigInt(100)).reduceLeft(_*_)
                        ^
scala> List.range(1, 100).map(BigInt(_)).product
res3: scala.math.BigInt = 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000
scala> List.range(1, 100).map(BigInt(_)).product.toString.toCharArray
res4: Array[Char] = Array(9, 3, 3, 2, 6, 2, 1, 5, 4, 4, 3, 9, 4, 4, 1, 5, 2, 6, 8, 1, 6, 9, 9, 2, 3, 8, 8, 5, 6, 2, 6, 6, 7, 0, 0, 4, 9, 0, 7, 1, 5, 9, 6, 8, 2, 6, 4, 3, 8, 1, 6, 2, 1, 4, 6, 8, 5, 9, 2, 9, 6, 3, 8, 9, 5, 2, 1, 7, 5, 9, 9, 9, 9, 3, 2, 2, 9, 9, 1, 5, 6, 0, 8, 9, 4, 1, 4, 6, 3, 9, 7, 6, 1, 5, 6, 5, 1, 8, 2, 8, 6, 2, 5, 3, 6, 9, 7, 9, 2, 0, 8, 2, 7, 2, 2, 3, 7, 5, 8, 2, 5, 1, 1, 8, 5, 2, 1, 0, 9, 1, 6, 8, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
scala> List.range(1, 100).map(BigInt(_)).product.toString.toCharArray.map(_.toInt - 48).sum
res5: Int = 648