Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int a;
- int b = 0;
- cin >> a;
- if (a == 1)
- {
- cout << "";
- }
- if (a == 2)
- {
- cout << "2";
- }
- if (a > 2)
- {
- cout << "2" << " " << "3" << " ";
- for (int i = 5; i <= a; i += 2)
- {
- for (int j = 2; j <= sqrt(i); )
- {
- j++;
- if ((i % j) == 0)
- {
- break;
- }
- else
- {
- if (j > sqrt(i))
- {
- cout << i << " ";
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement