Solve problem 206 using Scala.
Fix integer overflow issue on 32-bit Linux.