MeehoweCK

Untitled

Apr 14th, 2023
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     if (n == 1)
  10.     {
  11.         cout << 1;
  12.         return 0;
  13.     }
  14.     int suma = 1;
  15.     int i;
  16.     for (i = 2; i*i < n; i++)
  17.     {
  18.         if(n % i == 0)
  19.             suma += (i + n/i);  //cout << ' ' << i << ' ' << n/i;
  20.     }
  21.     if(i*i == n)
  22.         suma += i;  //cout << ' ' << i;
  23.  
  24.     cout << "Suma dzielnikow wlasciwych dla liczby " << n << " wynosi " << suma << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment