function modPow (base, exponent, modulus) {
        // exponent can be huge, use non-recursive variant
        let accumulator = 1
        while (!exponent.eq(0)) {
          if (exponent.mod(2).eq(0)) {
            exponent = exponent.div(2)
            base = base.mul(base).mod(modulus)
          } else {
            exponent = exponent.sub(1)
            accumulator = base.mul(accumulator).mod(modulus)
          }
        }
        return accumulator
      }
Test whether a value is prime: has no divisors other than itself and one.
The function supports type `number`, `bignumber`.

The function is evaluated element-wise in case of Array or Matrix input.

Syntax:

    math.isPrime(x)

Examples:

   math.isPrime(3)                     // returns true
   math.isPrime(-2)                    // returns false
   math.isPrime(0)                     // returns false
   math.isPrime(-0)                    // returns false
   math.isPrime(0.5)                   // returns false
   math.isPrime('2')                   // returns true
   math.isPrime([2, 17, 100])           // returns [true, true, false]

See also:

   isNumeric, isZero, isNegative, isInteger

@param {number | BigNumber | bigint | Array | Matrix} x  Value to be tested
@return {boolean}  Returns true when `x` is larger than zero.
                   Throws an error in case of an unknown data type.