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