Question: Problem with naief discrete logarithm algorithm

Dear mapleprimes users,

I have a problem concerning this function:

Naief := proc(A::integer,B::integer, p::posint)
local x, a:= A mod p, b:= B mod p;

 for x from 1 to p-1 do
    if a^x mod p = b then return x end if
end do;
print(¨No solution.¨)

end proc

It works fine for what it should do, finding x for a^x = b mod p by inserting x from 1 to p-1 until it finds an
apprioperate x.

My problem is concerning its computation time, which I like to calculate with:

Codetools:- Usage(Naief(a,b,p), output = [cputime], quiet, iterations= 2^12)

The problem is that keeps repeating

alot even when a,b and p are immensely huge. I don`t know how to fix it, because I need real CPUtimes which increase
a,b and p increase. I get the idea that the values of the CPUtime are not realistic.

 

Thanks for the help!

 

 

 

Please Wait...