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