Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
21
Task/Modular-exponentiation/GAP/modular-exponentiation.gap
Normal file
21
Task/Modular-exponentiation/GAP/modular-exponentiation.gap
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Built-in
|
||||
a := 2988348162058574136915891421498819466320163312926952423791023078876139;
|
||||
b := 2351399303373464486466122544523690094744975233415544072992656881240319;
|
||||
PowerModInt(a, b, 10^40);
|
||||
1527229998585248450016808958343740453059
|
||||
|
||||
# Implementation
|
||||
PowerModAlt := function(a, n, m)
|
||||
local r;
|
||||
r := 1;
|
||||
while n > 0 do
|
||||
if IsOddInt(n) then
|
||||
r := RemInt(r*a, m);
|
||||
fi;
|
||||
n := QuoInt(n, 2);
|
||||
a := RemInt(a*a, m);
|
||||
od;
|
||||
return r;
|
||||
end;
|
||||
|
||||
PowerModAlt(a, b, 10^40);
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
julia> a = BigInt("2988348162058574136915891421498819466320163312926952423791023078876139")
|
||||
b = BigInt("2351399303373464486466122544523690094744975233415544072992656881240319")
|
||||
m = BigInt(10)^40
|
||||
powermod(a, b, m)
|
||||
1527229998585248450016808958343740453059
|
||||
Loading…
Add table
Add a link
Reference in a new issue