Obtain the C ++ Implementation of the prime number optimization embedding method less than N

Source: Internet
Author: User

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
     
    
   
  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.