Encryption Maple中的试除法算法
我在Maple中有以下试用除法算法代码:Encryption Maple中的试除法算法,encryption,cryptography,rsa,maple,Encryption,Cryptography,Rsa,Maple,我在Maple中有以下试用除法算法代码: TrialDivision := proc( n :: integer ) if n <= 1 then false elif n = 2 then true elif type( n, 'even' ) then false else for local i from 3 by 2 while i * i <= n
TrialDivision := proc( n :: integer )
if n <= 1 then
false
elif n = 2 then
true
elif type( n, 'even' ) then
false
else
for local i from 3 by 2 while i * i <= n do
if irem( n,i) = 0 then
return false
end if
end do;
true
end if
end proc:
TrialDivision:=proc(n::integer)
if n允许在整个过程体中进行局部声明是对Maple语言的一种新添加
比如说,你可以把它改成这个
TrialDivision := proc( n :: integer )
local i;
if n <= 1 then
false
elif n = 2 then
true
elif type( n, 'even' ) then
false
else
for i from 3 by 2 while i * i <= n do
if irem( n,i) = 0 then
return false
end if
end do;
true
end if
end proc:
TrialDivision:=proc(n::integer)
本地i;
如果此帮助页面包含有关Maple proc甚至内部proc的有用信息,请参见页面中的最后一个示例,这是非常有趣的。