Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int pr(int x)
- {
- if (x % 2 == 0 || x == 1)
- return 0;
- for (int d = 3; d * d <= x; d += 2)
- if (x % d == 0)
- return 0;
- return 1;
- }
- int sdiv(int x)
- {
- int s = 0;
- for (int d = 1; d * d <= x; d++)
- if (x % d == 0)
- {
- s += d;
- if (d != x / d)
- s += x / d;
- }
- return s;
- }
- int main()
- {
- int n;
- cin >> n;
- for (int x = 0; x <= n; x++)
- if (pr(sdiv(x)))
- cout << x << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement