Advertisement
STANAANDREY

ex5

Jan 18th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {//problema 5
  7.  unsigned long n,d,S;
  8.  cout<<"n=";cin>>n;
  9.    //a
  10.    S=1+n;;
  11.   for (d=2;d<=sqrt(n);d++)
  12.     if (n%d==0)
  13.   {
  14.       S+=d;
  15.       if (n/d>d)
  16.       S+=n/d;
  17.   }
  18.   cout<<"Suma="<<S<<endl; //suma tuturor div sai
  19.   //b
  20.   S-=n;
  21.   if (S==n)
  22.     cout<<"nr e perfect";
  23.   else
  24.     cout<<"nr nu e perfect";
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement