Modular exponentiation: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added syntax colouring the hard way |
Alextretyak (talk | contribs) Added 11l |
||
Line 12:
The algorithm must work for any integers <math>a, b, m</math> <br>where <math>b \ge 0</math> and <math>m > 0</math>.
<br><br>
=={{header|11l}}==
{{trans|D}}
<lang 11l>F pow_mod(BigInt =base, BigInt =exponent, BigInt modulus)
BigInt result = 1
L exponent != 0
I exponent % 2 != 0
result = (result * base) % modulus
exponent I/= 2
base = (base * base) % modulus
R result
print(pow_mod(BigInt(‘2988348162058574136915891421498819466320163312926952423791023078876139’),
BigInt(‘2351399303373464486466122544523690094744975233415544072992656881240319’),
BigInt(10) ^ 40))</lang>
{{out}}
<pre>
1527229998585248450016808958343740453059
</pre>
=={{header|Ada}}==
|