0

我需要它在每次 a = 0 (mod p) 时显示消息。但它只有在 a 实际上为 0 时才会这样做。例如,如果我插入 Legendre(11,11),我会得到“-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;
4

1 回答 1

1

a = 'mod'(0, p)应该0 = 'mod'(a, p)

请参阅文档

于 2011-11-23T00:03:25.630 回答