0
What formula shoul i use?
In the task there is given number n, which is the number of roots and formula looks like sqrt(2+sqrt(2+...)). And my code looks like: #include <iostream> #include <cmath> using namespace std; int main() { int n, i; float c; cin>>n; i=0; while(i<n){ c=sqrt(2+sqrt(2)); i++; } cout<<c ; return 0; } What should I do so the code was right? https://code.sololearn.com/cTt8609x7Rwh/?ref=app
5 Réponses
+ 4
c=sqrt(2+c);
+ 2
Error is there in 13th line
Write cout<<c; instead of "cout c ;"
+ 1
I didn't get you Aruzhan , what did you mean? kindly elaborate
0
Thanks, but how to calculate this formula?
Like input:
1
Output:
1.4
Input:
2
Output:
1.8
0
It should calculate n roots, like if input is 1, then c=sqrt(2), so the output is 1.4
If input is 2, then c=sqrt(2+sqrt(2)), so the output is 1.8 and so on