9 lines
132 B
Text
9 lines
132 B
Text
|
|
func expmod(a, b, n) {
|
||
|
|
var c = 1
|
||
|
|
do {
|
||
|
|
(c *= a) %= n if b.is_odd
|
||
|
|
(a *= a) %= n
|
||
|
|
} while (b //= 2)
|
||
|
|
c
|
||
|
|
}
|