Advertisement
nguyenhappy92

Tính S(n) = 1/2 + 2/3 + 3/4 + ... + (n-1)/n

Sep 16th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. // Tinh S(n) = 1/2 + 2/3 + 3/4 + ... + (n-1)/n
  2. // Khai bao thu vien
  3.  
  4. #include<stdio.h>
  5. #include<conio.h>
  6.  
  7. void main()
  8. {
  9. // khai bao bien
  10. int n;
  11. // nhap du lieu
  12. scanf("%d",&n);
  13. float s=0;
  14. for(int i=2;i<=n;i++)
  15. {
  16. s=s+(float) (i-1)/i;
  17. }
  18. printf("%.2f",s);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement