Tonelli-Shanks algorithm: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: removed test value causing crash)
m (→‎{{header|Perl 6}}: Restore failing test as bug in compiler has been fixed)
Line 1,208: Line 1,208:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|Rakudo|2018.02}}
{{works with|Rakudo|2018.04}}
Translation of the Wikipedia pseudocode, heavily influenced by Sidef and Python.
Translation of the Wikipedia pseudocode, heavily influenced by Sidef and Python.


Line 1,254: Line 1,254:
(665820697, 1000000009),
(665820697, 1000000009),
(881398088036, 1000000000039)
(881398088036, 1000000000039)
(41660815127637347468140745042827704103445750172002,
100000000000000000000000000000000000000000000000577)
);
);


Line 1,261: Line 1,263:
say "Roots of $n are ($t, {$p-$t}) mod $p";
say "Roots of $n are ($t, {$p-$t}) mod $p";
}</lang>
}</lang>

<!-- fails with 'Cannot unbox 164 bit wide bigint into native integer', but save for eventual restore:
(41660815127637347468140745042827704103445750172002,
100000000000000000000000000000000000000000000000577)
-->
{{out}}
{{out}}
<pre>Roots of 10 are (7, 6) mod 13
<pre>Roots of 10 are (7, 6) mod 13
Line 1,273: Line 1,272:
Roots of 665820697 are (378633312, 621366697) mod 1000000009
Roots of 665820697 are (378633312, 621366697) mod 1000000009
Roots of 881398088036 are (791399408049, 208600591990) mod 1000000000039
Roots of 881398088036 are (791399408049, 208600591990) mod 1000000000039
Roots of 41660815127637347468140745042827704103445750172002 are (32102985369940620849741983987300038903725266634508, 67897014630059379150258016012699961096274733366069) mod 100000000000000000000000000000000000000000000000577</pre>
</pre>
<!-- Roots of 41660815127637347468140745042827704103445750172002 are (32102985369940620849741983987300038903725266634508, 67897014630059379150258016012699961096274733366069) mod 100000000000000000000000000000000000000000000000577 -->


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==