c 2b 2b primality test

Solutions on MaxInterview for c 2b 2b primality test by the best coders in the world

showing results for - "c 2b 2b primality test"
Diego Alejandro
23 Nov 2019
1#include <iostream>
2using namespace std;
3bool isPrimeNumber(int n) {
4    if (n <= 1) return false;
5    if (n <= 3) return true;
6    if (n % 2 == 0 || n % 3 == 0) return false;
7  
8    for (int i = 5; i * i <= n; i = i + 6)
9        if (n % i == 0 || n % (i + 2) == 0)
10            return false;
11  
12    return true;
13}