isPrime method

bool isPrime()

Checks if this integer is a prime number.

Implementation

bool isPrime() {
  if (this <= 1) return false;
  for (var i = 2; i <= math.sqrt(this).toInt(); i++) {
    if (this % i == 0) return false;
  }
  return true;
}