Advertisement
aimon1337

Untitled

Mar 14th, 2021
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void f(int n) {
  4.   int s = 1, d, j, nr = 0;
  5.   for (d = 3; d <= n; d++) {
  6.     if (d % 2 == 0 && n % d == 0)
  7.       s = s + d;
  8.     else if (n % d == 0 && d % 2 == 1) {
  9.       for (j = 3; j * j <= d; j = j + 2)
  10.         if (d % j == 0)
  11.           nr++;
  12.       if (nr != 0)
  13.         s = s + d;
  14.     }
  15.     nr = 0;
  16.   }
  17.   cout << s;
  18. }
  19. int main() {
  20.     int x;cin>>x;
  21.   f(x);
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement