#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
for (int i = 2; i * i <= x; i++)
if (x % i == 0)
return 0;
return 1;
}
int main() {
freopen("prime.out", "w", stdout);
ios::sync_with_stdio(false);
for (int i = 2; i <= 100000000; i++)
if (is_prime(i))
cout << i << endl;
fclose(stdout);
return 0;
}
所需时间较长,请耐心等待。结果是这样的:
55,528kb