Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int divizor(int x)
- {
- int s=0;
- for(int i=2;i<=x/2+1;i++)
- if(x%i==0)
- s+=i;
- return s+1+x;
- }
- int main()
- {
- int sumadiv=0;
- int nr; cout<<"nr= "; cin>>nr;
- while(nr!=0)
- {
- sumadiv+=divizor(nr);
- cout<<"nr= "; cin>>nr;
- }
- cout<<endl<<"suma divizorilor este: "<<sumadiv;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement