How many decimals are there before I'd need to add 1 when rounding? When you round a number, if the next digit is &gt;= 5 you add 1. For example:

3.1415926535 rounded to 1dp is 3.1
3.1415926535 rounded to 4dp is 3.1416    &lt;-- Note the 5 changed to 6
3.1415926535 rounded to 5dp is 3.14159

3.1415926535 rounded to 9dp is 3.141592654  &lt;-- Note the 3 changed to 4


You challenge is to receive an integer as input and output the number of decimal places before which you would have to round the square root of the number - i.e. the number of decimal places before anumber digit which is &gt;= 5 occurs.

The integer will be between 0 and 100,000 inclusive so for the edge case of 59752 you need to support 17 decimal points (to check the 17th).

If you programming language can't change the number of decimal points, you can display a "?" message to the user.

Example:

Input    Root                     Output

    5 -&gt; 2.23 606797749979     -&gt; 2
   41 -&gt; 6.40312423 743284     -&gt; 8      (Largest gap under 100)
  596 -&gt; 24.4131112314 674     -&gt; 10     (Largest gap under 1000)
59752 -&gt; 244.44222221212112029 -&gt; 16     (Largest gap under 100000)


Do what you want on perfect squares.

This is code-golf so shortest code wins.



For anyone interested, the number 310,617 is the biggest under 1,000,000 and has 18 before you reach a digit &gt;= 5.
CJam, 17 bytes

rie40mQsJ~&gt;'4f&gt;1#


Try it online.