Jump to content

Montgomery reduction: Difference between revisions

→‎{{header|Perl}}: Formatting, add libheader
(Added Perl example)
(→‎{{header|Perl}}: Formatting, add libheader)
Line 676:
=={{header|Perl}}==
{{trans|Perl 6}}
{{libheader|ntheory}}
<lang perl>use bigint;
use ntheory qw(powmod);
Line 708 ⟶ 709:
printf "Recovered from r2: %s\n", montgomery_reduce($m, $r2);
 
print "\nMontgomery computation x1**x2 mod m: \n";
my $prod = montgomery_reduce($m, $t1/$x1);
my $base = montgomery_reduce($m, $t1);
Line 726 ⟶ 727:
Recovered from r2: 515692107665463680305819378593
 
Montgomery computation x1**x2 mod m: 151232511393500655853002423778
151232511393500655853002423778
Built-in op computation x1**x2 mod m: 151232511393500655853002423778</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.