话不多说直接上代码:
#include<iostream>
#include<cstring>
using namespace std;
int res[10000];
int cnt;
long long su[100000000];
bool isprime[200000000];
void prime() {memset(isprime,1,sizeof(isprime));cnt=1;isprime[0]=isprime[1]=0;for(int i = 2; i<=200000000; i++ ) {if(isprime[i]) {su[cnt++]=i;
// if(cnt>5760000) printf("%d ",su[cnt-1]);}for(int j = 1 ; j<cnt && su[j]*i<200000000; j++) {isprime[su[j]*i]=0;}} printf("\n\n\n\n\n两亿以内的素数有 cnt = %d 个\n\n\n\n\n",cnt);
}
int main()
{int n = 593442147;int tmp=n;int top=0;prime();printf("OKOKOKOKKOKOKOKOKOKOKOK\n");for(int i = n-1; i>2; i--) {if(n%i==0) {res[++top]=i;printf("%d\n",i);}if(top>9999) break;}printf("top = %d \n" ,top);for(int i = 1; i<=top; i++) {if(isprime[ res[i] ]) {printf("符合条件的 = %d\n",res[i]);}}return 0;
}
总结一下:1.一亿以内的素数大概5760000个,两亿以内的素数大概1000W个
2.另 素数的模板 记住
嗯
嗯
’