Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tinh S(n) = 1/(1*2) + 1/(2*3) + ... + 1/(n*(n+1))
- // Khai bao thu vien
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- // khai bao bien
- int n;
- // nhap du lieu
- scanf("%d",&n);
- float s=0;
- for(int i=1;i<=n;i++)
- {
- s=s+ (float) 1/(i*(i+1));
- }
- printf("%.2f",s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement