isPrime property

bool get isPrime

检查是否为质数

Implementation

bool get isPrime {
  if (this < 2) return false;
  if (this == 2) return true;
  if (isEven) return false;

  for (int i = 3; i * i <= this; i += 2) {
    if (this % i == 0) return false;
  }
  return true;
}