Karim Belabas on Sun, 14 Nov 2004 15:14:35 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Lists and residue classes |
* Justin Walker [2004-11-14 05:33]: > > On Nov 13, 2004, at 19:58, John Kerl wrote: > > >Re the second, do you mean something other than: > > > > n = 11; > > v=vector(n); > > for(i=0,n-1,v[i+1]=Mod(i,n)); > > Yes; I was hoping for a magic bullet (something of a one-liner) :-}. n = 11; vector(n, i, Mod(i-1,n)); :-) > Since I'm looking for reduced residue classes, the actual > (straight-forward) algorithm is a little more involved. What's a reduced residue class ? coprime to modulus ? If so, something like n = 12; ind = 0; v = vector( eulerphi(n) ); for(i=1,n, if (gcd(i,n) == 1, v[ind++] = i)); does the trick. A sligthly more involved construction could be n = 12; ind = 0; v = vector(eulerphi(n), i, until(gcd(ind,n)==1, ind++); ind) Karim. -- Karim Belabas Tel: (+33) (0)1 69 15 57 48 Dep. de Mathematiques, Bat. 425 Fax: (+33) (0)1 69 15 60 19 Universite Paris-Sud http://www.math.u-psud.fr/~belabas/ F-91405 Orsay (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]