Advertisement
nguyenhappy92

S(n)=sqrt (2+sqrt (2+sqrt (2+ sqrt (2+.............sqrt(2)).

Oct 24th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. /* Tinh S(n)=sqrt (2+sqrt (2+sqrt (2+ sqrt (2+.............sqrt(2)).....)))
  2. có n dau can.
  3. */
  4. // Khai bao cac ham thu vien neu cos
  5. #include<stdio.h>
  6. #include<conio.h>
  7. #include<math.h> // thu vien cho sqrt, abs,...
  8. void main()
  9. {
  10. int n;
  11. scanf("%d",&n);
  12. double s=0;
  13. for(int i=1;i<=n;i++)
  14. {
  15. s=sqrt(2+s);
  16. }
  17. printf("%.4lf\n",s);// Lay 4 chu so sau dau thap phan
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement