Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int sz = 10000000;
- bool isnt_prime[sz + 1];
- void fix() {
- isnt_prime[0] = isnt_prime[1] = true;
- for (int i = 4; i <= sz; i += 2) isnt_prime[i] = true;
- for (int i = 3; i <= sqrt(sz); i++) {
- if (!isnt_prime[i]) {
- for (int j = 3; j * i <= sz; j += 2) isnt_prime[i * j] = true;
- }
- }
- }
- int main() {
- fix();
- for (int i = 0; i <= 100; i++) {
- if (!isnt_prime[i]) cout << i << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement