RosettaCodeData/Task/Modular-exponentiation/11l/modular-exponentiation.11l

15 lines
473 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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))