Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {//problema 5
- unsigned long n,d,S;
- cout<<"n=";cin>>n;
- //a
- S=1+n;;
- for (d=2;d<=sqrt(n);d++)
- if (n%d==0)
- {
- S+=d;
- if (n/d>d)
- S+=n/d;
- }
- cout<<"Suma="<<S<<endl; //suma tuturor div sai
- //b
- S-=n;
- if (S==n)
- cout<<"nr e perfect";
- else
- cout<<"nr nu e perfect";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement