Advertisement
nguyenhappy92

Tính 1+1/3+1/5+...+1/(2n+1)

Oct 22nd, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. // Khai bao ham thu vien neu co
  2. #include<stdio.h>
  3. #include<conio.h>
  4.  
  5. void main()
  6. {
  7. int n;
  8. scanf("%d",&n);
  9. float s=0;
  10. if(n==0)
  11. {
  12. printf("1");
  13. }
  14. else
  15. {
  16. for(int i=1;i<=n;i+=2)
  17. {
  18. s=s+ (float)1/((2*i)+1);
  19. }
  20. printf("%.3f\n",s);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement