Untitled
unknown
plain_text
2 years ago
462 B
18
Indexable
#include <stdio.h>
#include <math.h>
int main()
{
int end = 0, count = 1;
double diff, a1 = 2, a2 = 0, temp = 0;
a2 = a1;
scanf("%lf", &diff);
while (end != 1) {
temp = a2;
a2 = a1 + 1/a2;
count++;
if (fabs(a2 - temp) < diff) {
printf("%d %.6lf %.6lf", count, temp, a2);
return 0;
}
}
return 0;
}Editor is loading...