Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int divizor(int x)
  5. {
  6. int s=0;
  7. for(int i=2;i<=x/2+1;i++)
  8. if(x%i==0)
  9. s+=i;
  10. return s+1+x;
  11. }
  12. int main()
  13. {
  14. int sumadiv=0;
  15. int nr; cout<<"nr= "; cin>>nr;
  16. while(nr!=0)
  17. {
  18. sumadiv+=divizor(nr);
  19. cout<<"nr= "; cin>>nr;
  20. }
  21. cout<<endl<<"suma divizorilor este: "<<sumadiv;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement