ValerianBenchea

Suma divizorilor unui numar

Nov 20th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, s=0, d;
  7.     cout<<"n="; cin>>n;
  8.     for(d=2; d<=n/2; d++)
  9.     {
  10.         if(n%d==0)
  11.         {
  12.             s=s+d;
  13.             cout<<d<<" ";
  14.         }
  15.     }
  16.     cout<<"\n"<<s;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment