Advertisement
rotti321

Suma Divizori

Oct 19th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. unsigned long long n,S=0;
  6. int d;
  7. cin>>n;
  8.  
  9. if(n==1){ ///caz particular n=1
  10. cout<<1;
  11. }
  12. else
  13. {
  14. S= 1 + n;
  15. for(d=2;d*d<n;d++){
  16. if(n%d==0){
  17. S=S+d+n/d;
  18. }
  19. }
  20.  
  21. if(d*d==n){
  22. S=S+d;
  23. }
  24. cout<<S<<'\n';
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement