Isqrt (integer square root) of X: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (→{{header|MAD}}: Change this to use the quadratic residue method) |
Not a robot (talk | contribs) (→{{header|APL}}: Change this to use the quadratic residue method) |
||
Line 516: | Line 516: | ||
=={{header|APL}}== |
=={{header|APL}}== |
||
{{Incorrect|APL| <br><br> The method used by this APL program is '''not''' the method that this task requires, namely: <br><br> quadratic residue. <br><br>}} |
|||
Works in [[Dyalog APL]] |
Works in [[Dyalog APL]] |
||
<lang APL> |
<lang APL> i←{x←⍵ |
||
q←(×∘4)⍣{⍺>x}⊢1 |
|||
⊃{ r z q←⍵ |
|||
q←⌊q÷4 |
|||
t←(z-r)-q |
|||
r←⌊r÷2 |
|||
z←z t[1+t≥0] |
|||
r←r+q×t≥0 |
|||
r z q |
|||
}⍣{ r z q←⍺ |
|||
q≤1 |
|||
}⊢0 x q |
|||
}</lang> |
|||
{{output}} |
{{output}} |
||
<pre> |
<pre> |