checkPrimeNum

    0

    0

    Krazyguy2205

    The code checks to see if n is prime by checking if n is less than 2 and also testing for primes by dividing n by each of the integers 2, 3, 5, 7, and 11.

    bool isPrime(int n) {
      if(n < 2) return false;
      for(int i = 2; i <= sqrt(n); i++) {
        if(n % i == 0) return false;
      }
      return true;
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.