I found that the BigInteger trait is missing the modulus operation, i.e., the possibility of computing a % b at least for two positive BigIntegers. To implement this, we can refer to "The Art Of Computer Programming" by Donald Knuth, Section 4.3, Algorithm D. Such algorithm implement division with remainder, and it can be directly used to compute the modulus.