Advertisement
nguyenhappy92

Tính tổng tất cả ước số chẵn của số nguyên dương n

Oct 8th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // Tinh tong tat ca uoc so chan cua so nguyen duong n
  2.  
  3. // Khai bao thu vien
  4. #include<stdio.h>
  5. #include<conio.h>
  6.  
  7. void main()
  8. {
  9. int n;
  10. scanf("%d",&n);
  11. long s=0;
  12. for(int i=1;i<=n;i++)
  13. {
  14. if(n%i==0)
  15. {
  16. if(i%2==0)// so chan
  17. {
  18. s=s+i;
  19. }
  20. }
  21. }
  22. printf("%ld",s);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement