Answers for "sqrt primality testing"

0

sqrt primality testing

bool isPrime(int n) {

  if (n == 1) {
    return false;
  }

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

  return true;
}
Posted by: Guest on December-05-2020

Browse Popular Code Answers by Language