Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void eratosfen (int n)
- {
- long long *arr = new long long[21474836];
- for (long long p = 0; p < 21474836; p++)
- arr[p] = p;
- int index = 0;
- for (long long p = 2; p < 21474836 && index < n; p++)
- {
- if (arr[p] != 0)
- {
- index++;
- cout << arr[p] << " ";
- for (long long j = p*p; j < 21474836; j += p)
- arr[j] = 0;
- }
- }
- }
- int main()
- {
- int n = 0;
- cin >> n;
- eratosfen(n);
- }
Add Comment
Please, Sign In to add comment