Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tính S(n) = 1 + 1/3 + 1/5 + ... + 1/n
- // 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++)
- {
- if(n%2!=0)
- {
- s=s+(float) 1/i;
- }
- }
- printf("%.2f",s);
- }
Advertisement
Add Comment
Please, Sign In to add comment