Isqrt (integer square root) of X: Difference between revisions

→‎{{header|MAD}}: Change this to use the quadratic residue method
(Add CLU)
(→‎{{header|MAD}}: Change this to use the quadratic residue method)
Line 2,142:
 
=={{header|MAD}}==
 
{{incorrect|MAD| <br><br> The algorithm used is not the one that is mandated to be used by the task's requirements: <br><br> finding the integer square root by using a &nbsp;<u>quadratic residue</u>&nbsp; method &nbsp; (as shown my the pseudo-code). <br><br>}}
 
<lang MAD> NORMAL MODE IS INTEGER
Line 2,151 ⟶ 2,148:
INTERNAL FUNCTION(X)
ENTRY TO ISQRT.
X0Q = X/21
FNDPW4 WHENEVER X0Q.ELE.0, FUNCTION RETURN X
STEP X1 Q = (X0Q +* X/X0)/24
WHENEVER X1.GE.X0, FUNCTION RETURN X0TRANSFER TO FNDPW4
X0END =OF X1CONDITIONAL
TRANSFERZ TO= STEPX
R = 0
FNDRT WHENEVER Q.G.1
Q = Q / 4
T = Z - R - Q
R = R / 2
WHENEVER T.GE.0
Z = T
R = R + Q
END OF CONDITIONAL
TRANSFER TO FNDRT
END OF CONDITIONAL
FUNCTION RETURN R
END OF FUNCTION
2,124

edits