Obtain the C ++ Implementation of the prime number optimization embedding method less than N
Correlation theorem and inference of twin prime numbers (adjacent prime numbers with an interval of 2) P1: when n is not less than 6 and N-1 and N + 1 are twin prime numbers, then N must be a multiple of 6 T1: when n is not less than 1 and N = 6x-1 or N = 6x + 1 is not a prime number, N must not be a multiple of P2 of 2 and 3: if N is a prime number when N is not less than 5, then N mod 6 = 1 or N mod 6 = 5T2: A number greater than 5 has a prime number, and only the division of 6 remainder is 1 or 5.
The remainder of a division of 6 May be 1, 2, 3, 4, 5, but the remainder is 2, 3, and 4.
The Code is as follows:
/*************************************** * ************************** NAME: select_prime.cpp * DESC: * AUTHOR: Liu Dongguo (jealdean@outlook.com) * VERSION: 1.0 * CREATE: 13:59:45 * LUTIME: 01:53:40 ** Copyright (c) 2007-2015 abdu.com, Inc. all Rights Reserved ************************************* * ***************************/# include
# Include
# Include
Char * GetPrimesLessN (int nSize) // nSize is the upper limit {int fLen = nSize; char * flag = new char [fLen]; // memset (flag, 'y ', fLen); flag [0] = flag [1] = 's'; // exclude 0 and 1 for (int I = 2; I * I