Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double calculate(double epsilon) {
- double last = sqrt(0.5);
- double current = sqrt(0.5 + (0.5 * last));
- double result = last * current;
- while (abs(current - last) >= epsilon) {
- last = current;
- current = sqrt(0.5 + (0.5 * current));
- result = result * current;
- }
- return result;
- }
- int main()
- {
- double epsilon;
- cin >> epsilon;
- cout << 4.0/calculate(epsilon);
- system("pause");
- }
Add Comment
Please, Sign In to add comment