Isqrt (integer square root) of X: Difference between revisions
fixed example to correctly implement integer square roots
(→{{header|Arturo}}: marked as incorrect, the integer sqrt root used isn't using the method as required by the task (the pseudo-code that uses a quadratic residue).) |
Drkameleon (talk | contribs) (fixed example to correctly implement integer square roots) |
||
Line 286:
=={{header|Arturo}}==
<lang rebol>commatize: function [x][
Line 293 ⟶ 291:
]
isqrt: function [x][
print map 0..65 => [sqrt.integer]▼
num: new x
q: new 1
r: new 0
while [q =< num]-> shl.safe 'q 2
while [q > 1][
shr 'q 2
t: (num-r)-q
shr 'r 1
if t >= 0 [
num: t
r: new r+q
]
]
return r
]
loop range 1 .step: 2 72 'n ->
print [n "\t" commatize
{{out}}
|