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