View Code of Problem 74

#include<stdio.h>
#include<math.h>
#include<string.h>
//#include<algorithm>
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	scanf("%d",&n);
	double x=1;
	double x1=(x+n/x)/2;
	while(abs(x1-x)>=0.00001) {
		x=x1;
		x1=(x+n/x)/2;
	}
	printf("%.3lf",x1);

}

Double click to view unformatted code.


Back to problem 74