I need it to show the message every time a = 0 (mod p). But it only does it when a is actually 0. For example, if I plug Legendre(11,11), I get "-1".
Legendre := proc (a, p)
local L; if a = `mod`(0, p) then
"Coose a different integer";
else if a = -1 then
L := (-1)^((1/2)*p-1/2);
else
L := `mod`(a^((1/2)*p-1/2), p);
end if;
if L = 1 then
L else L := -1;
L end if end if;
end proc;