Tính S(n) = sqrt(2+sqrt(2+sqrt(2+...+sqrt(2+sqrt(2)))))
BÀI TOÁN
Viết chương trình tính S(n) = sqrt(2+sqrt(2+sqrt(2+...+sqrt(2+sqrt(2))))) lấy căn n lần. Với n được nhập từ bàn phím
CHƯƠNG TRÌNH MẪU
Code:
#include "conio.h"
#include "stdio.h"
#include "math.h"
void main(){
clrscr();
int n;
float S = 0;
printf("Nhap vao n = ");
scanf("%d",&n);
for(int i=0; i<n; i++)
S = sqrt(2+S);
printf("Ket qua: %.38f",S);
getch();
}