18 lines
581 B
Plaintext
18 lines
581 B
Plaintext
procedure main()
|
|
a := 2988348162058574136915891421498819466320163312926952423791023078876139
|
|
b := 2351399303373464486466122544523690094744975233415544072992656881240319
|
|
write("last 40 digits = ",mod_power(a,b,(10^40))
|
|
end
|
|
|
|
procedure mod_power(base, exponent, modulus) # fast modular exponentation
|
|
if exponent < 0 then runerr(205,m) # added for this task
|
|
result := 1
|
|
while exponent > 0 do {
|
|
if exponent % 2 = 1 then
|
|
result := (result * base) % modulus
|
|
exponent /:= 2
|
|
base := base ^ 2 % modulus
|
|
}
|
|
return result
|
|
end
|