Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by yuji bolado ( 14 years ago )
testeForte (n, b) ==
    k := 1
    q:INT:= 1 
    t:= false
    
    if b>n-1 then
        b:=powmod(b,1,n)
    if b=0 then
        return ERRO
        
    while rem(q,2)=0 repeat
        q:=quo((n-1),(2**k))
        k:=k+1
        
    i := 0
    r := powmod(b,q,n)
    if r~=1 then
        while(i<k and r ~= n-1) repeat
            r := powmod(r,2,n)
            i := i + 1
        if i = k then
            t := true

    return t

 

Revise this Paste

Your Name: Code Language: