ITeye博客

project_Eular problem10:求小于2000000的质数之和

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

typedef  long long lint;

 

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(){

lint  res = 0;

for(int i=2; i<2000000; i++){

if(isZs(i)){

res += i;

cout << res<<endl;

}

}

cout << res <<endl;

return 0;

}

评论(0)

暂无评论。

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