Montgomery reduction: Difference between revisions

Content added Content deleted
imported>Katsumi
(Added Quackery.)
Line 1,472: Line 1,472:
Alternate computation of x1 ^ x2 mod m :
Alternate computation of x1 ^ x2 mod m :
151232511393500655853002423778
151232511393500655853002423778
</pre>

=={{header|Quackery}}==

<syntaxhighlight lang="Quackery"> [ 0 swap
[ dup while
dip 1+
1 >> again ]
drop ] is bits ( n --> n )

[ over bits times
[ dup 1 & if
[ over + ]
1 >> ]
swap mod ] is monred ( n n --> n )

$ "750791094644726559640638407699 440160025148131680164261562101 monred"
dup echo$ say " --> " quackery echo cr
$ "750791094644726559640638407699 435362628198191204145287283255 monred"
dup echo$ say " --> " quackery echo cr </syntaxhighlight>

{{out}}

<pre>750791094644726559640638407699 440160025148131680164261562101 monred --> 540019781128412936473322405310
750791094644726559640638407699 435362628198191204145287283255 monred --> 515692107665463680305819378593
</pre>
</pre>