The first consumer calculators provided four arithmetic operators and square root, the latter using an iterative algorithm based on the Newton-Raphson method for finding roots of equations.

To determine the square root of a positive real number k, given any approximation xi > 0 calculate

to obtain a value closer to the root. Keep applying the formula to obtain better approximations. Stop when successive approximations differ by 1e–10.

Write a program that calculates the square root of a number read from input. The initial approximation can be 1 or k, as the algorithm converges quite quickly.

Step 1

Run your program on the following three test cases. In the main competition mostly there will usually be one test file to minimise time spent on submission.

Test Input
2
9.8696044010893586188344909998762
1000000

Step 2

Cut and paste the input and output of your program for each of the test cases into the box below:

Step 3

Paste the source code for your program into the box below:

Step 4

When you are sure all the data has been entered correctly on the form press the submit button below.

You may submit multiple times. Only your most recent submission for each task in the open round will be marked.