Accepted answer

Just to get the comments into an answer here, so the question can be resolved...

1) BigInt is bigger than Int; specifically, it's bigger than Int.MaxValue. Your second example is overflowing and 9415087488 is the correct answer.

2) Using vars like this is strongly discouraged in Scala. A more "functional" solution is to map the characters to BigInts then use .product


Related Query