Montgomery reduction: Difference between revisions

m
(→‎{{header|Quackery}}: multiple improvements)
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 1,480:
<code>**mod</code> is defined at [[Modular exponentiation#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ 0 swap [ dup while dip 1+ 1 >> again ] drop ] is bits ( n --> n )
 
[ 1 & ] is odd ( n --> b )
 
[ over bits times [ dup odd if [ over + ] 1 >> ] swap mod ] is monred ( n n --> n )
 
[ 750791094644726559640638407699 ] is m ( --> n )
Line 1,515:
cr
say "Montgomery computation of x1^x2 mod m: " x1 x2 m **mon echo cr
say "Modular exponentiation of x1^x2 mod m: " x1 x2 m **mod echo cr</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
Line 1,819 ⟶ 1,818:
{{trans|Kotlin}}
{{libheader|Wren-big}}
<syntaxhighlight lang="ecmascriptwren">import "./big" for BigInt
 
class Montgomery {
9,479

edits