算法 筛法求素数 由埃拉托斯特尼(Eratosthenes,约公元前274~194年)发明,又称埃拉托斯特尼筛子。 基本思路 不是挑选出所有素数,而是筛掉所有的合数; #include <iostream> #include <cmath> using namespace std; int main(){ int i, sum = 0, a[100] = {0}; for (i = 2; i < sqrt(100.0); i++){ sum