In number theory, the integer square root (isqrt) of a non-negative integer n is the non-negative integer m which is the greatest integer less than or equal to the square root of n,
isqrt ( n ) = ⌊ n ⌋ . {\displaystyle \operatorname {isqrt} (n)=\lfloor {\sqrt {n}}\rfloor .}
For example, isqrt ( 27 ) = ⌊ 27 ⌋ = ⌊ 5.19615242270663... ⌋ = 5. {\displaystyle \operatorname {isqrt} (27)=\lfloor {\sqrt {27}}\rfloor =\lfloor 5.19615242270663...\rfloor =5.}
Introductory remark Let y {\displaystyle y} and k {\displaystyle k} be non-negative integers. Algorithms that compute (the decimal representation of) y {\displaystyle {\sqrt {y}}} run forever on each input y {\displaystyle y} which is not a perfect square. Algorithms that compute ⌊ y ⌋ {\displaystyle \lfloor {\sqrt {y}}\rfloor } do not run forever are nevertheless capable of computing y {\displaystyle {\sqrt {y}}} up to any desired accuracy k {\displaystyle k} . Choose any k {\displaystyle k} and compute ⌊ y × 100 k ⌋ {\textstyle \lfloor {\sqrt {y\times 100^{k}}}\rfloor } . For example (setting y = 2 {\displaystyle y=2} ):
k = 0 : ⌊ 2 × 100 0 ⌋ = ⌊ 2 ⌋ = 1 k = 1 : ⌊ 2 × 100 1 ⌋ = ⌊ 200 ⌋ = 14 k = 2 : ⌊ 2 × 100 2 ⌋ = ⌊ 20000 ⌋ = 141 k = 3 : ⌊ 2 × 100 3 ⌋ = ⌊ 2000000 ⌋ = 1414 ⋮ k = 8 : ⌊ 2 × 100 8 ⌋ = ⌊ 20000000000000000 ⌋ = 141421356 ⋮ {\displaystyle {\begin{aligned}&k=0:\lfloor {\sqrt {2\times 100^{0}}}\rfloor =\lfloor {\sqrt {2}}\rfloor =1\\&k=1:\lfloor {\sqrt {2\times 100^{1}}}\rfloor =\lfloor {\sqrt {200}}\rfloor =14\\&k=2:\lfloor {\sqrt {2\times 100^{2}}}\rfloor =\lfloor {\sqrt {20000}}\rfloor =141\\&k=3:\lfloor {\sqrt {2\times 100^{3}}}\rfloor =\lfloor {\sqrt {2000000}}\rfloor =1414\\&\vdots \\&k=8:\lfloor {\sqrt {2\times 100^{8}}}\rfloor =\lfloor {\sqrt {20000000000000000}}\rfloor =141421356\\&\vdots \\\end{aligned}}}
Compare the results with 2 = 1.41421356237309504880168872420969807856967187537694... {\displaystyle {\sqrt {2}}=1.41421356237309504880168872420969807856967187537694...}
… excerpt ends here. Continue reading the full article.
