ITeye博客

project_Eular problem7:求从最小素数开始求第 10001个素数

gqboy · 2012-10-12 12:16 · 算法 · 编程语言 · Markdown

#include <iostream>

 

#include <windows.h>

#include <math.h>

#include   <algorithm>

using namespace std;

bool isZs(long num) {

if(num < 2) return false;

for (int i = 2; i <= sqrt(num); i++) {

if ((num % i) == 0)

return false;

}

return true;

}

 

int main(int argc, char** argv) {

 

int j=0;

int res=0;

for(int i=2; j<10001; i++){

if(isZs(i)){

res = i;

j++;

}

}

cout << res << endl;

return 0;

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。