I think a powmod function should be part of std.math. It's important for many types of algorithms for avoiding overflow and it's not something that the average person can write off the top of their head.
Currently I'm using a powmod code that I found on the internet. I'm not even sure what the licensing terms of it are.
Comment #1 by josvanuden — 2015-09-28T19:29:07Z
ulong powmod(ulong b, ulong e, ulong m) {
ulong r = 1;
for (; e > 0; e >>= 1) {
if (e & 1) {
r = (r * b) % m;
}
b = (b * b) % m;
}
return r;
}
Comment #2 by github-bugzilla — 2017-10-16T17:46:17Z