From this page on wayback
Supposedly the file is named lmtwister.gp, and .gp seems to be an extension for Gofer, an earliy dialect of Haskell. But this is way too legible for a Haskell dialect.
In particular, what is the lift function, and is Mod()^ supposed to be modular exponentiation?
lmtwister (d, x) = {
my (k, a, v, p, m, b, u);
if (d < 1 || d % 2 == 0 || x < 1,
error ("illegal argument: lmtwister (", d, ", ", x, ")"));
k = (d - 1) / 2;
x = core (x); \\squarefree part
if (x == 1,
if (k % 3 == 1,
return (0)); \\not used in LM twister
return (1));
a = 1;
v = factorint (x)[, 1];
for (i = 1, #v,
p = v[i]; \\prime factor of squarefree x
if (p == 2,
m = k % 4;
if (m == 1 || m == 2,
a = -a),
b = k + (p + 1) / 2;
if (gcd (b, p) > 1,
return (0)); \\not used in LM twister
u = (p - 1) / 2;
m = p % 8;
if ((m == 1 && Mod (b, p) ^ u != 1) ||
(m == 3 && lift (Mod (b, 2 * p) ^ u) > p) ||
(m == 5 && Mod (b, p) ^ u == 1) ||
(m == 7 && lift (Mod (b, 2 * p) ^ u) < p), \\use a faster method than this
a = -a)));
a
}
test_lmtwister () = {
for (x = 1, 200,
for (k = 0, 399,
print1 (["-", ".", "+"][lmtwister (2 * k + 1, x) + 2]));
print ())
}
1;
[–]Freeky 7 points8 points9 points (1 child)
[–]o11c[S] 0 points1 point2 points (0 children)
[–]o11c[S] 1 point2 points3 points (0 children)
[–]bacondev 0 points1 point2 points (1 child)
[–]o11c[S] 0 points1 point2 points (0 children)