TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Primality test implementation. More...
#include <iostream>
Go to the source code of this file.
Functions | |
bool | IsPrime (int number) |
int | main () |
Primality test implementation.
A simple and efficient implementation of a function to test if a number is prime, based on the fact that
Every Prime number, except 2 and 3, are of the form \(6k\pm1\) for integer values of k. This gives a 3x speed improvement.
Definition in file primality_test.cpp.
bool IsPrime | ( | int | number | ) |
Check if a number is prime
[in] | number | number to check |
Definition at line 18 of file primality_test.cpp.
int main | ( | void | ) |
main function
Definition at line 31 of file primality_test.cpp.