j"19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAutMcontract Test() {
function normalize(int k, int modulus) : int {
k = k % modulus;
if (k < 0) {
k = k + modulus;
}
k
}
// n must be positive
function inverse(int a, int n) : int {
a = normalize(a, n);
int t = 0;
int newt = 1;
int r = n;
int newr = a;
int quotient = 0;
int tmp = 0;
for (11) {
if (newr != 0) {
quotient = r / newr;
tmp = newt;
newt = t - quotient * newt;
t = tmp;
tmp = newr;
newr = r - quotient * newr;
r = tmp;
}
}
//if (r > 1)
// return 0; // "a is not invertible"
if (t < 0)
t = t + n;
t
}
challenge test(int y) {
int x = 43148;
int m = 15485863;
int invX = inverse(x, m);
verify 12747089 == invX;
verify normalize((x * invX) % m, m) == 1;
}
}
https://whatsonchain.com/tx/dedf4e438eb76d380dea23c56b114470d79e16f567fc00fdc24f63e32ebfc0e4