Dirk Laurie on Wed, 11 Jul 2012 14:01:17 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Hello


2012/7/11 Ahmad Kamal <drkamal.mtc@gmail.com>:
> Hi , i want to ask please about the command      x=random(p)    :
>
> what if i want to be sure that x has an inverse Mod p .
>
> cause in the following program it always give an error :
>
>
> n=5;
> p=281040463189842761944876463095882573657425678131112457182259869008082819;
> X=listcreate(n);
> for(x=1,n,listput(X,random(p),x)) ;
>
> invX=listcreate(n);
> for(x=1,n,listput(invX,lift(Mod(X[x],p)^-1),x)) ;
>


? p=281040463189842761944876463095882573657425678131112457182259869008082819;
? isprime(p)
0

If you are going to use non-primes for p, then of course the inverse mod p is
not going to exist always.