2013-12-13 45 views
0

我試圖在楓樹實施費爾馬攻擊,但它給了我一個錯誤,指出Error,unexpected。超級初學者與楓樹,所以如果任何人誰有一定的經驗可以幫助,這將不勝感激。使用楓實施費馬攻擊

而且,我試圖因素的整數,125位長。有誰知道在楓樹任何有效的算法或任何其他程序可以處理和係數的這種大整數?

FermatAtttack:=proc(n::And(posint,odd), maxnumsteps::posint:=10^7,(numsteps::truefalse:=false)) 
local x, k, r, i, y: 
x:=isqrt(n); 
if x^2 < n then 
    x:= x+1 
end if; 
k:=2*x+1; 
r:=x^2-n; 
for i to maxnumsteps while not issqr(r) do 
    r:=r+k; 
    k:=k+2 
end do; 
if issqr(r) then 
    x:=(k-1)/2; 
    y:=isqrt(r) 
else 
    error "%1 could not facot in %2 iteratioons", n, maxnumsteps 
end if; 
if not numsteps then 
    x-y, x+y 
else 
    x-y, x+y, i 
end if; 
end proc: 

回答

0

你將需要使用Number Field Sieve來將您的125位整數作爲因子,請參閱this guide開始。

0

錯誤消息是一個簡單的語法錯誤。您的第一行可能應該是

FermatAtttack:=proc(n::And(posint,odd), maxnumsteps::posint:=10^7,{numsteps::truefalse:=false}) 

Maple使用命令「ifactor」來分解整數。

0

在您的程序FermatAttack定義的參數序列中,在括號內的參數聲明中有一個圓括號的項目,並且您的錯誤消息是由於此。

(numsteps::truefalse:=false) 

改變,要要麼只是,

numsteps::truefalse:=false 

,或者,

{numsteps::truefalse:=false} 

根據你打算如何在調用它。其中的第二個被稱爲關鍵字參數。以下是差異的簡要說明。

FA := proc(ns::truefalse:=false) 
    print(ns); 
end proc: 

FA(); 
           false 

FA(true); 
           true 

FB := proc({ns::truefalse:=false}) 
    print(ns);       
end proc:       

FB(); # getting the default value 
           false 

FB(ns=false); 
           false 

FB(ns=true); 
           true 

FB(ns); # a convenience of type truefalse keyword parameters 
           true 

如果使用關鍵字參數的方法,然後注意,在下面的例子中傳遞的參數true不匹配的關鍵字(其因此獲得它的缺省值)。

FB(true); 
           false