Advertisement
MeehoweCK

Untitled

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