Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n; cin >> n;
- bool* er = new bool[n]; // До n невключительно.
- for (int i = 0; i < n; ++i) {
- er[i] = true;
- }
- er[0] = false;
- er[1] = false;
- for (int x = 2; x < n; ++x) {
- if (er[x]) {
- for (int k = 2; k * x < n; ++k) {
- er[k * x] = false;
- }
- }
- }
- for (int i = 0; i < n; ++i) {
- if (er[i]) cout << i << " ";
- }
- delete[] er;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement